Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NJohnson9402/7a54eaf14baf2fc0a5b6fc1796ed1039 to your computer and use it in GitHub Desktop.
Save NJohnson9402/7a54eaf14baf2fc0a5b6fc1796ed1039 to your computer and use it in GitHub Desktop.
Trigger_AfterDelete_LogEvidence
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
@NJohnson9402
Copy link
Author

NJohnson9402 commented May 5, 2018

See full repo @ https://github.com/NJohnson9402/Demo-Audit-Delete-Trigger/ ; this is merely broken-out for ease of blogging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment