Bèlguesmi Sémah Bèlguesmi Sémah - 1 year ago 157
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')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download