Dapper. Execute Query with GOs

GO is not a SQL statement it is merely a batch separator, in fact you could rename it to whatever you want.

batch seperator

The way Management Studio figures this out is by parsing the SQL. It is easy to write a trivial parser that can chunk the statements up. Just split the string on "GO" and send each statement to Dapper.

However, to be 100% correct you need a sophisticated parser.

select '
GO ' GO from [GO] 

Dapper cannot help you here. Instead, I would suggest you try SQL Server Management Objects to execute large SQL commands like the one you mentioned. And it does supports GO statements.

You can check out this blog post for step-by-step instructions.

Tags:

Sql

Dapper