Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
Hii,

I have a table called Employee. In which i have columns Employee Id and manager Id.. (Manager Id is nothing but Employees only)

One Employee can be set to As a manager for many Employees ..

I want to write one procedure in which if Any Employee deleted , Whwere that Employee is set as Manager , those Employees Manager Id changes to 0 .. Please suggest me SP for that
Posted

1 solution

SQL
UPDATE Employee
SET EmployeesManagerID = 0
WHERE EmployeeID = @EmployeeID

DELETE FROM Employee WHERE EmployeeID = @EmployeeID


Then just wrap it in a transaction and check for error and either commit or rollback.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900