Error in SQL Server Merge Statement: The column prefix 'Updated' does not match with a table name or alias name used in the query

StackOverflow https://stackoverflow.com/questions/20913088

  •  24-09-2022
  •  | 
  •  

質問

I have the following SQL statement and I get the error:

MERGE Target_Table AS Tg
USING #Temp_SourceTable AS So
ON (Tg.COl1 = So.COL1 AND 
    Tg.COL2 = So.COL2AND 
    Tg.COL3= So.COL3)
WHEN MATCHED THEN 
    Update set Tg.COl4= Tg.COL4 + So.COL4,
           Tg.COL5= '2014-01-03'
OUTPUT $action, Updated.*;

Error: The column prefix 'Updated' does not match with a table name or alias name used in the query

Any thoughts on what I am missing here??

役に立ちましたか?

解決

Updated just does not exist. There are just INSERTED and DELETED. For updates, both are filled. Use INSERTED to get the new values.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top