/ Published in: SQL

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 ;)
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 ;)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
CREATE TRIGGER dbo.InsertTriggerOnGUIDYourtable ON dbo.YourTable FOR INSERT AS BEGIN SET NOCOUNT ON SELECT GUIDCol AS '@@GUID' FROM inserted END
Comments
