|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Bring Data As It Is Inserted With Select StatementMy Question is how to bring data from a table as it is inserted. What i
will use with Order by clasue in Select statement. The only unique Filed I got Newid() in this table. Hi,
Use a Insert trigger. Inside the trigger you could use the INSERTED vitual table to select. It just contains the newly inserted records only... Thanks Hari SQL Server MVP <afzal91***@gmail.com> wrote in message Show quote news:1156422062.975723.237820@m79g2000cwm.googlegroups.com... > My Question is how to bring data from a table as it is inserted. What i > will use with Order by clasue in Select statement. The only unique > Filed I got Newid() in this table. > I guess that by specifying - "as it is inserted" you mean in the order
that the records were inserted. If so, then you can't use the global unique identifier, because the values that are generated with the NEWID() function are not guaranteed to be incremented each time that you use the function. You can have a datetime column that will have the default value of getdate(), but you can still have records with the same value. If you can add an identity column (or replace the GUID column with an identity column) then you'll have a way to know the order that the records were inserted into the table. If you work with SQL Server 2005, then you can work with the function NEWSEQUENTIALID() instead if NEWID() function. NEWSEQUENTIALID() function does guarantee to increment the value each time that you use it to generate a new GUID (unlike NEWID() function that only guarantee to have a unique value each time that you use it. Adi afzal91***@gmail.com wrote: Show quote > My Question is how to bring data from a table as it is inserted. What i > will use with Order by clasue in Select statement. The only unique > Filed I got Newid() in this table. |
|||||||||||||||||||||||