Home All Groups Group Topic Archive Search About

Creating multiple Stored procedure on SQL Server through ADO

Author
21 Oct 2005 9:05 AM
Pushkar
Hi,

I want to create a set of procedures through my application on SQL Server, through ADO.

My Scipts is something of the form:

Use DB1
Go
create procedure <procedurename>
as
< procedure text>
Go

Create Procedure <procedurename>
as
<procedure text>
Go

But when I execute this statement it gives error 'Error in line 2 Go'

Is there a way to excute this script in a single call or I have to make multiple calls.

Thanks
Pushkar

Author
21 Oct 2005 9:20 AM
Jens
Instead of GO use a semicol for this:

Use DB1;
create procedure <procedurename> ...

HTH, Jens Suessmeyer.
Author
21 Oct 2005 10:32 AM
Erland Sommarskog
Jens (J***@sqlserver2005.de) writes:

> Instead of GO use a semicol for this:
>
> Use DB1;
> create procedure <procedurename> ...
>
> HTH, Jens Suessmeyer.
>

   use tempdb;
   CREATE PROCEDURE blafs AS
   SELECT 'Uhuh'

gives:

   Server: Msg 111, Level 15, State 1, Line 2
   'CREATE PROCEDURE' must be the first statement in a query batch.

; is a statement terminator, handled by SQL Server.

GO is a batch terminator, handled client-side by some query tools.

GO and ; fills different purposes.

--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
Author
21 Oct 2005 9:44 AM
Tibor Karaszi
You can't pass GO through ADO, as GO isn't a SQL command. For each GO, do an .Execute of your
command object.

"Pushkar" <pushkartiw***@gmail.com> wrote in message news:uDUQl6h1FHA.736@tk2msftngp13.phx.gbl...
Hi,

I want to create a set of procedures through my application on SQL Server, through ADO.

My Scipts is something of the form:

Use DB1
Go
create procedure <procedurename>
as
< procedure text>
Go

Create Procedure <procedurename>
as
<procedure text>
Go

But when I execute this statement it gives error 'Error in line 2 Go'

Is there a way to excute this script in a single call or I have to make multiple calls.

Thanks
Pushkar

AddThis Social Bookmark Button