I have a table:
Employee (employeeID) EmployeeRank (rankID, employeeID)
Now I have one more table in which there are all employees who are going to get a promotion.
DueForRaise (rankID, employeeID)
I need to insert all the employees who are in DUeForRaise into the EmployeeRank table ONLY if they do not already exist with the same rank.
I am doing this update for the rankID parameter, @rankID.
Will this work?
INSERT EmployeeRank ( rankID, employeeID) SELECT rankID, employeeID FROM DueForRaise dfr OUTER JOIN EmployeeRank er er.employeeid = dfr.employeeid) WHERE dfr.rankID = @rankID
source share