Thandava Vallepalli
asked on
how to update a table recursively sql server 2005?
Hello Experts,
There is an Employee table with (Empid, empname, ManagerID, salary)
i need toi update salary for all employees of s perticular manager? I am trying with recursive CTE syntax. But no luck.
Could you please help me on this?
Thanks,
itsvtk
There is an Employee table with (Empid, empname, ManagerID, salary)
i need toi update salary for all employees of s perticular manager? I am trying with recursive CTE syntax. But no luck.
Could you please help me on this?
Thanks,
itsvtk
Do you need recursion? What about:
UPDATE Employee SET ...
WHERE ManagerID = @MgrID
UPDATE Employee SET ...
WHERE ManagerID = @MgrID
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is it possible to explain with some sample data and how do you want to update?
;WITH CTE_EmpList ( ManagerID )
AS (
-- anchor members
SELECT e.ManagerID
FROM Employee e
WHERE ManagerID = @managerID
UNION ALL
-- recursive members
SELECT e.ManagerID
FROM Employee e
INNER JOIN CTE_EmpList d ON e.ManagerID = d.EmployeeID
)