devxlogo

Determine the Identity Value of Inserted Row(s)

Determine the Identity Value of Inserted Row(s)

IN tblTicker table we have following fields:

 	[CompanyID] INT IDENTITY (1,1)	[TickerSymbol] [char] (10) NULL	[ClassOfShare] [char] (10) NULL

We inserted some rows and deleted some from table tblTicker.Now At the time of fresh insertion if we will use the following code we will get the identity value of inserted row.

 INSERT INTO tblTicker(TickerSymbol,ClassOfShare)VALUES('SRCE','A')SELECT @@IDENTITY

If the table tblTicker was having 5 rows and then we deleted any two rows. Now if we insert one row the Identity value will be 6.

devx-admin

Share the Post: