Wednesday, May 21, 2014

Get Identity after inserting into database in Ms. SQL Server

Suppose we have a table named tblUser with coloumn name
Id int auto increment primary key
Name nvarchar(255)
Email nvarchhar(255)

Now after inserting a value into tblUser an Id will automatic generate as Id. Now how will you retrieve that Id. Very simple.

After inserting code place the bellow code

SELECT @@IDENTITY

This one will return you the Id of the inserted row.

0 comments:

Post a Comment

Popular Posts

Pageviews