There are different methods to know the Identity Value of a newly added row.
Let us consider the following example:
--Create a Table
CREATE TABLE test
id int identity(1,1),
INSERT INTO test(names) SELECT 'testing'
--Get Identity Value that is Populated in the Current Scope
--Get Identity value that is Populated in the Current Session
--Get Identity value that is Populated in the Table
--Regardless of Scope and Session
Note that first two methods wont give correct values if data are added to the ‘different tables’.
Did you like this post?
|subscribe via rss||subscribe via e-mail|
|print this post||follow me on twitter|