Wednesday 16 October 2013

08. Create a trigger named Emp_Delete_Trg on the EmployeeDetails table. This trigger should restrict the deletion of records from the table if the designation of an employee is Manager.

create trigger emp_Delete_Trg
on employeeDetails After Delete
as
Begin
Declare @job varchar(50)
select @job=Designation from deleted
if @job='Manager'
begin
Rollback
print ('Cannot Delete Manager from The Table')
end
end

No comments:

Post a Comment