return ID after INSERT with a SP?

  • Thread starter Thread starter DraguVaso
  • Start date Start date
D

DraguVaso

Hi,

I thought there was a way to do an INSERT of a record with a Stored
Procedure, and return the ID of the new record to the application.

How do you do this if it can be done?


Thanks a lot,

Pieter
 
I presume that you refer to a table which has the column with the IDENTITY
property?

Yes, use the SCOPE_IDENTITY function after your INSERT. You can either
return it as a result set (doing SELECT after the INSERT) or using an OUT
parameter for the stored procedure.
 
Back
Top