views:

15

answers:

1

The situation is:

I want to create two stored procedures:

query1 = CREATE PROCEDURE MyProc1 AS SELECT * FROM TEST1;

and

query2 = CREATE PROCEDURE MyProc2 AS SELECT * FROM TEST2;

I can do it using

command.CommandText = query1;
command.ExecuteNonQuery();
command.CommandTest = query2;
command.ExecuteNonQuery();

Is it possible to create these two procedures in one ExecuteNonQuery(), like:

command.CommandText = query1 + query2;
command.ExecuteNonQuery();
+1  A: 

No, everything within a single call of ExecuteNonQuery is executed as a single batch. To quote from CREATE PROCEDURE:

The CREATE PROCEDURE statement cannot be combined with other Transact-SQL statements in a single batch.

Damien_The_Unbeliever
@Damien_The_Unbeliever Thank you very much.
Kamil_H