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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving primary key value from the table i just inserted

Status
Not open for further replies.

cctrinh

MIS
Feb 2, 2001
25
US
Is there a way to retrieve a primary key from the table that I just inserted using Transact SQL? I need to obtain a primary key from the table I just inserted so that I can use that primary key to insert into another table. Any help will be great.

Thank you so much.
 
Declare @NewId Integer

-- Put the insert here

Select @NewId = Scope_Identity()





-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top