views:

173

answers:

0

We are using Smo.Server to run some SQL batches.
For queries that create stored procedures or tables and contain the separator GO the following code works:

server.ConnectionContext.ExecuteNonQuery(sql);

But the following fails

server.ConnectionContext.ExecuteWithResults(sql);

For sql that doesn't change the database structure it seems that using GO works fine on both.
I can see that ExecuteWithResults supports DDL, because it runs successfully CREATE TABLE.
But it doesn't support

CREATE TABLE ...
GO
SELECT 1

This last query works with no problems if I use ExecuteNonQuery
What do I need to do to be able to run this last query and access to the result DataSet?