What does SCOPE_IDENTITY function does in Sql Server?

 Posted by vishalneeraj-24503 on 2/3/2015 | Category: Sql Server Interview questions | Views: 417 | Points: 40
Answer:

SCOPE_IDENTITY returns the Last Identity Value for any table in the Same Session and the Same Scope.
Syntax:-
Select Scope_Identity();


For Example:-
insert into tbl(col1,col2) values('value1','value2');

Select Scope_Identity();

Output:-Would be Last Inserted Identity Column Value.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response