CAMPzxzxDeathzxzx
asked on
I need to find orphan records and update values to 0
Here's my try..
SELECT SalesUserID INTO Temp001 FROM [dbo].[Organization]
WHERE NOT EXISTS
(SELECT * FROM [dbo].[Users] WHERE UserID = SalesUserID)
Update [Organization]
Inner Join Temp_Organization
On Temp_Organization.SalesUserID = [Organization].SalesUserID
Set SalesUserID = 0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
Open in new window
For your specific case, if you do not need to do the intermediate step, you actually can do the UPDATE using the original WHERE NOT EXISTS.
Open in new window