您好我的mssql代码中出现异常。这是一个例外:
Incorrect syntax near the keyword 'set' and 'as'.
这是我的sql代码:
UPDATE SET TBLSurvey.Status=-1 FROM TBLSurvey
RIGHT JOIN (
SELECT OrderId
FROM [CRM_NEW].[dbo].[TBLSurvey]
GROUP BY OrderId HAVING(COUNT(*)>1)) AS sd ON TBLSurvey.OrderID=sd.OrderId
WHERE AnswerDate IS NULL AND Status=0
不知道。
答案 0 :(得分:3)
在SQL Server中,应该开始更新:
update TBLSurvey
set Status = -1
from TBLSurvey . . .
SQL Server中update
的语法是here。如果我不得不猜测,看起来你对MySQL语法的各个方面感到困惑。
答案 1 :(得分:2)
也许你的意思是:
UPDATE t
SET [Status] = -1
FROM dbo.TBLSurvey AS t
WHERE [Status] = 0
AND NOT EXISTS
(
SELECT 1 FROM CRM_NEW.dbo.TBLSurvey
WHERE OrderId = t.OrderId
GROUP BY OrderId HAVING COUNT(*) > 1
) AS sd;