I would be grateful if someone could show me how in SQL Server 2008 you can get the next free available row number in a database table?
What I am trying to do is implement something similar to Oracle where sequence numbers give the next number for a new row. Searching the internet, I haven’t found anything that matches this, but what I have found is row_number(). Unfortunately, I cannot make it work within a insert statement.
I think what you’re looking for is the IDENTITY property for a column. Using that allows SQL Server to auto-assign what you’re calling row numbers.
A quick example using
idas an IDENTITY column: