Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use a SQL Server identity column to determine the inserted order of rows?

I need to be able to determine the order which rows have been inserted into a table (there are no updates). Can I use an identity column to do this? I know that there may be gaps, but are the values guaranteed to be increasing by insertion order?

like image 831
Jon Avatar asked Apr 02 '09 07:04

Jon


1 Answers

Largely yes, as long as you don't ever reset it or insert rows with bulk copy, or use IDENTITY_INSERT. And of course assuming that you don't overflow the data-type (which could be impressive).

like image 73
Marc Gravell Avatar answered Oct 04 '22 20:10

Marc Gravell