How get last inserted ID in SQL Server 2012 -


how last inserted id in sql server 2012? shows null me.

enter image description here

assuming table is

create table test (     id int identity(1,1) primary key     , testdata varchar(100) not null ) 

this works

insert dbo.test (testdata) values ('test') select @@identity id 

as (better answer)

insert dbo.test (testdata) values ('test') select scope_identity() id 

i don't have enough information know why yours not work. in table structure? need more information answer this.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -