Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sp command

Status
Not open for further replies.

rbringas

Technical User
Joined
Jan 2, 2002
Messages
4
Location
US
Hello everyone...A newby at SQL server. I'm being asked this question:

I'm looking at a stored procedure and there is a command I don't know.

it is

set @page_id=@@IDENTITY

now I know that @page_id is a user defined variable, but I don't know what the @@IDENTITY is. I looked at my sql manuals here and it does not say. So I think it is a sql 7 syntax or reserved word. Its not used in oracle or sybase which I have manuals here for.

Thanks in advance.
 
It retrieves the last identity value created.

From the BOL:

This example inserts a row into a table with an identity column and uses @@IDENTITY to display the identity value used in the new row.

INSERT INTO jobs (job_desc,min_lvl,max_lvl)

VALUES ('Accountant',12,125)

SELECT @@IDENTITY AS 'Identity'

 
Thank you very much for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top