NiceYellowEgg
NiceYellowEgg

Reputation: 562

SQL Server Merge Statement - Incorrect Syntax

I'm getting the following error when executing this SQL script:

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];

Error:

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

I can't see where I've gone wrong!

Upvotes: 3

Views: 604

Answers (1)

fnurglewitz
fnurglewitz

Reputation: 2127

The keyword is WHEN, not WHERE :)

More about it here, but a bit much to put into an answer.

Upvotes: 6

Related Questions