Posted By

rengber on 08/31/09


Tagged

database sql insert db tsql query StoredProc


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


TSQL to Get the SQL Autonumber ID of the Row Just Inserted


 / Published in: SQL
 

Dead simple, but often forgotten.

  1. BEGIN
  2. INSERT INTO [dbo].[Transaction]
  3. (
  4. [TotalAmountPaid]
  5. ,[TransactionDttm]
  6. )
  7. VALUES
  8. (
  9. @TotalAmountPaid
  10. ,@TransactionDttm
  11. )
  12.  
  13. SELECT SCOPE_IDENTITY() AS 'TransactionID'
  14. END

Report this snippet  

You need to login to post a comment.