Mahmoud ElMansy: knowledge meant to be free

Get the next value of identity column

We are as programmers it is used to make Primary Key for table as Identity.
Now if we want to pre know the next value that will be assigned when inserting new row,
We can achieve that by calling SQL Function “IDENT_CURRENT” that get the current Value for the
Primary Identity Column.

SELECT IDENT_CURRENT ('dbo.TableName') AS Current_Identity;

And if we want to know the next value for the new inserted row we can do that,
by adding to current value the table seed for identity column using SQL Function “IDENT_INCR” .

SELECT IDENT_CURRENT('dbo.TableName') + IDENT_INCR('dbo.TableName') AS Next_Identity_Value;

I hope that this post helped.