Created
May 5, 2018 02:08
-
-
Save NJohnson9402/7a54eaf14baf2fc0a5b6fc1796ed1039 to your computer and use it in GitHub Desktop.
Trigger_AfterDelete_LogEvidence
This file contains 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
CREATE OR ALTER TRIGGER dbo.Victims_DEL | |
ON dbo.Victims | |
AFTER DELETE | |
AS | |
BEGIN | |
INSERT INTO aud.Evidence (SchemaName, TableName, ActionType, RecordID | |
, DatabaseUser, ServerLogin, ActionTime) | |
SELECT SchemName = 'dbo', TableName = 'Victims', ActionType = 'delete', RecordID = Deleted.Id | |
, DbUser = USER_NAME(), SrvLogin = SUSER_SNAME(), ActionTime = SYSDATETIME() | |
FROM Deleted; | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See full repo @ https://github.com/NJohnson9402/Demo-Audit-Delete-Trigger/ ; this is merely broken-out for ease of blogging.