Identity function
To get information about identity available on a table, sql server provides a set of functions that are collectively called as Identity functions
Ident_seed(‘tablename’)
Returns seed value of identity available on a given table
Returns identity increment value for the identity available on the given table
Ident_current(‘tablename’)
Returns the current value of identity available on the given table.
Example
select ident_current('emp')
select IDENT_SEED('emp')
select IDENT_INCR('emp')
There is a system variable @@identity that returns the identity value generated by last insert statement you executed
If the last inserted statement you executed did not generate an IDENTITY value than this variable will contain ‘NULL’
No comments:
Post a Comment
Thank you for visiting my blog