2012-11-14 97 views
3

执行此SQL脚本时,我收到以下错误:SQL Server的MERGE语句 - 语法错误

MERGE TridionCentres TridionCentres 
USING (SELECT * FROM #CentresToUpdate) NewInfo 
ON (TridionCentres.[publication id] = NewInfo.[publication id] AND 
    TridionCentres.centre_number = NewInfo.centre_number) 
WHERE matched THEN 
    UPDATE 
    SET TridionCentres.centre = NewInfo.centre, 
     TridionCentres.[date] = NewInfo.[date]; 

错误:

Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'WHERE'.

我不能看到我已经错了!

+6

该关键字是时,而不是在哪里:) http://technet.microsoft.com/en-us/library/bb510625.aspx – fnurglewitz

+2

@ tr3您应该添加您的评论作为答案。 (并可能发布固定查询) – Lamak

+0

为什么这么多人发表他们的答案作为评论? – 2012-11-14 14:33:54

回答

6

关键字时,不要在那里:)

更多关于它here,但有点多投入一个答案。