I am using SSMS 2008 and am trying to write a trigger now to update a uniqueidentifier field after an insert. How do I do this? Example data is below:
c1 c2 c3 c4
xxxx-xxxx-xxxx-xxxx A BB C5
xxxx-xxxx-xxxx-xxxx A2 BB C
xxxx-xxxx-xxxx-xxxx A3 BB C7
xxxx-xxxx-xxxx-xxxx A4 BB C
The table definition is:
CREATE TABLE dbo.rd_information3_cleaned (
c1 uniqueidentifier NULL,
c2 nvarchar(50),
c3 nvarchar(50),
c4 nvarchar(50)
)
So I want “c1” to automatically be updated to uniqueid after inserting data.
You need to set the default value of that column. NewId() will generate a new Guid for you.
Here’s a screen cap for the designer.