To get the next identity value from SQL Server

If you have table with no. of rows and you want to find out next id, following query can be used to identify:

SELECT IDENT_CURRENT(‘<Table Name>’) + IDENT_INCR(‘<Table Name>’)

You cannot reliably find out the next identity value – until you’ve actually inserted a new row into the table.

From the IDENT_CURRENT documentation:

When the IDENT_CURRENT value is NULL (because the table has never contained rows or has been truncated), the IDENT_CURRENT function returns the seed value.

Happy Coding 🙂

Leave a comment