Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » System FunctionsRSS Feeds

@@IDENTITY - IDENTITY Function

Posted By: Sarita Patel     Category: SQL Server     Views: 4263

This article explains about @@IDENTITY function in sql server with examples.

@@IDENTITY returne the last identity value generated in any table in the current session. 

After an INSERT, SELECT INTO, or bulk copy statement completes, @@IDENTITY contains the last identity value generated by the statement. 

If the statement did not affect any tables with identity columns, @@IDENTITY returns NULL. 

If multiple rows are inserted, generating multiple identity values, @@IDENTITY returns the last identity value generated. 

The scope of the @@IDENTITY function is the local server on which it is executed. This function cannot be applied to remote or linked servers. 


Syntax of @@IDENTITY Function :

@@IDENTITY

Return type of @@IDENTITY function is a numeric.




Examples of @@IDENTITY Function :

Example 1 : Use of @@IDENTITY function in select clause 

SELECT @@IDENTITY

Output
NULL

Above example returns null as in current session no rows are inserted in any table.
  
Share: 

 
 
 

Didn't find what you were looking for? Find more on @@IDENTITY - IDENTITY Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of @@IDENTITY - IDENTITY Function is from United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!