Wednesday 16 October 2013

11. John is a Database Developer. He is not able to delete the unwanted records from the base tables by using the view, Emp_Dept. Help John in resolving the problem.

create trigger view_delete_trg
on Emp_Dept Instead of delete
as
Begin
Declare @DeptNo int
declare @Count int
select @DeptNo=DeptNo from deleted
select @Count=Count(*) from EmployeeDetails
Where DeptNo=@DeptNo
delete from EmployeeDetails Where DeptNo=@DeptNo
if @Count=1
Delete from deptdetails where DeptNo=@deptNo
end

No comments:

Post a Comment