0

我有来自 SQL Server Management Studio 2005 的以下 T-SQL 代码:

UPDATE O
SET DATAREVISIONTYPE = 'Modify', O.OriginalUserID = OriginalUserID, O.EmployeeBirthdate = EmployeeBirthdate, O.User_ID = User_ID
FROM LRN_Upload_Prep as O
WHERE DATAREVISIONTYPE = 'Add' AND
(SELECT COUNT([OriginalUserId]) FROM Lrn_Upload_Prep WHERE DataRevisionType = 'Transfer' AND FirstName = O.FirstName 
AND LastName = O.LastName AND EmployeeEmailAddress = O.EmployeeEmailAddress AND LEFT(EmployeeBirthdate, 4) = O.EmployeeBirthdate)> 0

我无法弄清楚如何使用别名 (O.OriginalUserID = OriginalUserID, O.EmployeeBirthdate = EmployeeBirthdate, O.User_ID = User_ID) 修改 SET 中的数据,因为我的理解是尚未声明别名。我研究了将声明别名的部分包装在 CTE 中,认为这可能会起作用,但无济于事。任何修复,或关于研究什么的建议都会很棒,谢谢!

4

0 回答 0