Return a New IDENTITY Column Value

In this blog I will explain how to return identity column value in sql server.

Step 1: Create a table with Info name. I'm inserting into an SQL Server table with an autoincrementing key field.
 

CREATE TABLE [dbo].[info](

[Id] [int] IDENTITY(1,1) NOT NULL,

[name] [nvarchar](50) NULL,

[Phone] [int] NULL

) ON [PRIMARY]

GO

Inserting into an SQL Server table with an autoincrementing key field


Image1.jpg
 

Now executed this query and get recently add identity column value.

Image2.jpg
 

Now again select statement you will see one column add with new id column value.

Image3.jpg