Bèlguesmi Sémah Bèlguesmi Sémah - 11 months ago 54
ASP.NET (C#) Question

Next value of a tables identity specification - SQL Server

How can I get the next value of the identity specification using SQL Server?

Don't say

Select (id+1) from Table1
, because it gives wrong results when deleting rows.

Answer Source

First of all, whatever you are doing, you are likely doing something wrong, because concurrency.

But you can get the next value of the identity column using

select ident_current('TableName') + ident_incr('TableName')