SQL Inserted Trigger


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

This trigger returns a resultset that includes last inserted record's guid info (uniqueidentifier)

If your column is uniqueidentifier and its default value is newid() , you can't get last record id (guid) with @@identity .

So, I write a trigger on my table to get last record guid info ;)


Copy this code and paste it in your HTML
  1. CREATE TRIGGER dbo.InsertTriggerOnGUIDYourtable
  2. ON dbo.YourTable
  3. FOR INSERT
  4. AS
  5. BEGIN
  6. SET NOCOUNT ON
  7.  
  8. SELECT GUIDCol AS '@@GUID'
  9. FROM inserted
  10. END

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.