Breaking up insert statements with GO
PROBLEM NUMERO ONE

GO is the default query batch separator. It is a feature of certain client utilities (mainly SQLCMD and SSMS) and is unknown to the SQL Server engine itself. GO needs to be on a line by itself (optionally followed by only an INT value to cause repetition of that batch) as it is parsed by these client utilities to indicate where to split up what is being submitted to SQL Server.

It cannot be included in any Dynamic SQL as it is, again, unknown to SQL Server. It is also unnecessary to include in Dynamic SQL since each call to EXEC() is its own query batch.

So,


If you are generating a SQL script to exec via SSMS or SQLCMD, then simply put a newline / CRLF between COMMIT TRANSACTION; and GO
If you are generating Dynamic SQL to run each of these blocks via an EXEC(@SQL) call, then simply remove the GO.


PROBLEM NUMERO TWO

After fixing the GO situation, you will find that you still have a syntax error. It is also indicated in that you have two error messages. The problem is that you are missing the semicolon ( ; ) that needs to terminate the MERGE statement. If you try to execute after fixing the GO, you will get the following error:


  Msg 10713, Level 15, State 1, Line XXXXX
  A MERGE statement must be terminated by a semi-colon (;).


Just add a semicolon before the COMMIT TRANSACTION and the whole thing should work. As in:

values (cell,[date],valueFlag,[value]); -- &lt;-- that guy, right there :-)