MERGE statement must be terminated by a semi-colon

[expired user #10875]'s profile image [expired user #10875] posted 7 years ago in General Permalink

Hello,

the following MERGE query is working fine out of SQL Management Studio (11.0.6248.0; SQL Server 2012) but throws an error when executed in HeidiSQL portable (9.4 & 9.4.0.5174).

MERGE
    INTO Cube.dbo.MergeDB AS MDB
    USING (VALUES ('AAA','BBB')) AS X ([A],[B])
    ON (MDB.[WertA] = X.[A] AND MDB.[WertB] = X.[B])
    WHEN NOT MATCHED BY TARGET THEN
        INSERT (WertA,WertB)
        VALUES (X.[A],X.[B])
    OUTPUT $action, inserted.*;
/* SQL Error (10713): A MERGE statement must be terminated by a semi-colon (;) */
/* Affected rows: 0  Found rows: 0  Warnings: 0  Duration for 0 of 1 query: 0,000 sec. */

I think it the same problem reported by itaysk: .../forum.php?t=20928.

The query is not part of any stored function/procedure/trigger. It is executed on it's own.

Any hints would be highly appreciated :-) Thank you!

Best Regards,

Thomas

[expired user #11069]'s profile image [expired user #11069] posted 6 years ago Permalink

You've probably figured it out already. But any way, I'll respond just for reference and maybe others who run into this.

If you run the query, you have the option to send separate statements or run the query as a single statement.

See attached screen shot. The default seems to be 'send separate statements' which does not work. If you switch to 'single statement' it should work. It does here for me.

1 attachment(s):
  • Unbenannt

Please login to leave a reply, or register at first.