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


/ Published in: SQL
Save to your folder(s)

Dead simple, but often forgotten.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.