Implement Log on DELETE SQL Server


show more Implementing logging on DELETE provides you with in-depth training on Business. Taught by Martin Guidry as part of the SQL Server: Triggers, Stored Procedures, and Functions show less
please wait ...

Implementing logging on DELETE

For our DELETE stored procedure, the rules we're going to implement is the stored procedure can only delete one record at a time, and we must maintain a log of who deleted and when. So in order to maintain that log I'd like to create a new table that will be used for that logging. I have some code staged for that. It's a three column table; one column for user name, the person who did the deletion, one column for the ID that they deleted, and one column for the date. I also have some codes staged for the stored procedure. So starting at the top we have with CREATE PROCEDURE Students_Delete.

This time we are only taking one parameter. All I need is the ID of what you would like to delete. Line number 2 there is new to us. We're saying EXCUTE AS CALLER. There are some context in which a stored procedure might execute as the system, but in this one, one of my business requirements is to log who is running this. So I am going to specifically saying EXCUTE AS CALLER. Line 6 throug...

Implementing logging on DELETE
Video duration: 3m 58s 1h 52m Advanced

Viewers:

Implementing logging on DELETE provides you with in-depth training on Business. Taught by Martin Guidry as part of the SQL Server: Triggers, Stored Procedures, and Functions

Subjects:
Business Developer IT
Software:
SQL Server
Author:
please wait ...