Returns the last-inserted identity value.



SELECT @@IDENTITY AS TEMPNAME
or
SELECT @@IDENTITY AS [TEMPNAME]
or
SELECT @@IDENTITY AS "TEMPNAME"


numeric


If you create a table in SQL Server Compact 3.5 that uses an identity column and then run a query in which an INSERT fails, the value of @@IDENTITY will still increment.

Show: