MERGE statement must be terminated by a semi-colon

Thomas Michel posted 6 months ago in General


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 &

    INTO Cube.dbo.MergeDB AS MDB
    USING (VALUES ('AAA','BBB')) AS X ([A],[B])
    ON (MDB.[WertA] = X.[A] AND MDB.[WertB] = X.[B])
        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,


lobos posted 3 months ago

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.