XGIS
asked on
Update SQL Table Row with GUID after Identity Insert Complete
I need to insert a GUID value in each row after the row is inserted.
This needs to be done using a constraint of trigger to update immediately when the row insert is complete. Default NewID() as a Constraint does NOT work at the insert stage
The field must be set to NULL by default
This statement needs to be run when the table is created.
Pls advise..
This needs to be done using a constraint of trigger to update immediately when the row insert is complete. Default NewID() as a Constraint does NOT work at the insert stage
The field must be set to NULL by default
This statement needs to be run when the table is created.
Pls advise..
CREATE TRIGGER XTM1_Trigger_UpdateGUID_XTM1Manufacturers ON [dbo].[XTM1Manufacturers]
AFTER INSERT
AS BEGIN
UPDATE [dbo].[XTM1Manufacturers]
SET @ManufacturerGUID = NEWID() Where [dbo].[XTM1Manufacturers].ManufacturerID= @ManufacturerID
END
GO
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it works
AFTER INSERT
AS BEGIN
UPDATE [dbo].[XTM1Manufacturers]
SET @ManufacturerGUID = NEWID() Where [dbo].[XTM1Manufacturers].
END
GO