SQLTeam.com | Weblogs | Forums

MERGE statement containing UPDATE SET *

Hi,

I found this part in a MERGE statement.

MERGE INTO ... WHEN MATCHED THEN UPDATE SET *

What does the UPDATE SET * do?

Col 1 123

Col 2. 123

When matched condition
Col1 = Col2

Do update

Col 3 456

Col 3 999

Col3 456 becomes 999

Hi Harish,

You mean it updates all columns?

I'm typing this code in SSMS

...
WHEN MATCHED THEN UPDATE SET *
WHEN NOT MATCHED ...

SSMS underlines * WHEN in red, indicating an error: "Incorrect syntax near '*'. Expecting '.', ID, PSEUDOCOL, QUTED_ID, or VARIABLE."

When I execute it, (without the WHEN NOT MATCHED part) it gives:

Msg 102, Level 15, State 1, Line 23
Incorrect syntax near '*'.

Where did you find this syntax?

hi

this microsoft T-SQL merge command .. please see if this helps

syntax has to be EXACTLY right .. otherwise errors

I found this syntax in working code in the new company I work for now.

This may be Spark SQL, not t-SQL.

yeah I was going to say...