sql server get identity value before insert Edit

Murugan Andezuthu Dharmaratnam | 27 November 2020 | 175

I wanted to know the auto-generated identity value before I do an Insert statement. I have a table named setupcountry and I had set the NumercId column as identity with type integer.

Solution

select IDENT_CURRENT('yourtablename')            

                    

Returns the last identity value generated for a specified table. NULL is returned on error or if you do not have permission to view the object