sqlsql-server-2008sql-server-2008-r2merge-statement

SQL Server 2008 - Merge Script not working


This merge script i'm writing isn't compiling and I believe I have the correct syntax.

MERGE into MyTable ct_current
USING (SELECT '0%' as Description, '0' as ShareAmount) ct_value
    ON ct_current.ShareAmount = ct_value.ShareAmount
WHEN MATCHED THEN 
    UPDATE SET ct_current.Description = '0%'
WHEN NOT MATCHED THEN
    INSERT (Description, ShareAmount)
    VALUES (ct_value.Description, ct_value.ShareAmount);
GO

Error:

Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'into'. Msg 102, Level 15, State 1, Line 2 Incorrect syntax near 'ct_value'.


Solution

  • I realized that I had the SQL Server 2008 R2 client, but the server is SQL Server 2005.