Last active
January 27, 2019 20:34
-
-
Save jetstreamin/30afeae7706ffad1476942915e80ceb4 to your computer and use it in GitHub Desktop.
SQL - Row Update Trigger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Add the Modified field to the row | |
-- E.g. Add a column to the table using a create/alter statement like: | |
-- ... | |
-- Modified DATETIME2(3), | |
-- ... | |
-- Then create the trigger | |
CREATE TRIGGER updateModified | |
ON dbo.YourTable | |
AFTER UPDATE | |
AS | |
UPDATE dbo.YourTable | |
SET modified = SYSDATETIME() | |
FROM Inserted i | |
WHERE dbo.YourTable.PrimaryKey = i.PrimaryKey |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment