sql server Creating a trigger to work on delete in SQL server
Go to solution
Solved by Shammikit,
ok i managed to make one. if anyone else wants to know how its done you might find the example below useful
CREATE TRIGGER trgAfterDelete ON [Employee_Test] AFTER DELETE AS declare @empid int; declare @empname varchar(100); declare @empsal decimal(10,2); declare @audit_action varchar(100); select @empid=d.Emp_ID from deleted d; select @empname=d.Emp_Name from deleted d; select @empsal=d.Emp_Sal from deleted d; set @audit_action='Deleted -- After Delete Trigger.'; insert into Employee_Test_Audit (Emp_ID, Emp_Name, Emp_Sal, Audit_Action, Audit_Timestamp) values (@empid, @empname, @empsal, @audit_action,getdate()); PRINT 'AFTER DELETE TRIGGER fired.

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now