Re: Executing Stored Proc from file in Ado .NET
From: CliffNews (dainea_at_hotmail.com)
Date: 04/10/04
- Next message: Jason Coyne Gaijin42: "Re: Using one instance of SqlConnection in an ASP.NET page"
- Previous message: CliffNews: "Re: Executing Stored Proc from file in Ado .NET"
- In reply to: Joe Fallon: "Re: Executing Stored Proc from file in Ado .NET"
- Next in thread: Joe Fallon: "Re: Executing Stored Proc from file in Ado .NET"
- Reply: Joe Fallon: "Re: Executing Stored Proc from file in Ado .NET"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 10 Apr 2004 17:21:21 -0400
I forgot to mention one other thing, I actually replace 'GO' and tried to
run the script in Query Analyzer and got the same error as well.
"Joe Fallon" <jfallon1@nospamtwcny.rr.com> wrote in message
news:OI%23riazHEHA.1608@TK2MSFTNGP11.phx.gbl...
> I think the suggestion was to replace GO with ; everywhere in the file.
> This will send multiple SQL statements to SQL Server which has the ability
> to run them consecutively.
> So it should work.
> Some other DBs don't have this ability.
> --
> Joe Fallon
>
>
>
>
> "CliffNews" <dainea@hotmail.com> wrote in message
> news:LxWdc.10061$Ix2.591@fe30.usenetserver.com...
> > Thanks for the quick reply Val. I'm not sure if I quite follow you. Are
> you
> > saying for each statement in my batch I should terminate it with a (;).
> e.g
> >
> > if exists (select * from dbo.sysobjects
> > where id = object_id(N'[dbo].[delete_datafeed_response]')
> > and OBJECTPROPERTY(id, N'IsProcedure') = 1)
> > drop procedure [dbo].[delete_datafeed_response];
> >
> >
> > create procedure [dbo].[delete_datafeed_response] @day_delete_interval
int
> > as
> > begin
> > set nocount on
> > declare @error int, @message varchar(200), @rows_deleted int;
> > select @error = 0;
> >
> > if @day_delete_interval > 0
> > begin
> > DELETE FROM [delete_datafeed_response];
> > WHERE [status_code] = 'CLOSED';
> > AND (DATEDIFF(d, [modify_date], getdate()) >
> @day_delete_interval);
> >
> > end;
> >
> > I'm not sure if this is what you mean (that is putting semi-colon at the
> end
> > of each statement). If so that will be a pain considering the procs that
> i'm
> > executing can be rather huge in upwards of 4 megs. Streaming through
these
> > files and putting (;) at the end of each line will be pain.
> >
> > "Val Mazur" <group51a@hotmail.com> wrote in message
> > news:uZOxbEyHEHA.3356@TK2MSFTNGP11.phx.gbl...
> > > Hi,
> > >
> > > Since GO is not a valid SQL statement, but batch statement, you cannot
> use
> > > it in your batch. What you could do in this case is to separate your
> > > statements inside of the batch, suing semicolon (;). In this case
OLEDB
> > > provider for SQL Server will recognize each statement properly and
will
> > > execute them separately. But it works with SQL Server provider. Some
> other
> > > providers do not support this feature
> > >
> > > --
> > > Val Mazur
> > > Microsoft MVP
> > >
> > >
> > > "CliffNews" <dainea@hotmail.com> wrote in message
> > > news:R7Vdc.45006$W6.43639@fe08.usenetserver.com...
> > > > Hi all,
> > > > I'm trying to a automate the execution of a stored procedure from a
> > file.
> > > > The problem is when I remove the 'GO' command, I get "'CREATE
> PROCEDURE'
> > > > must be the first statement in a query batch." Is there a way around
> > > > this??
> > > > I would hate to have to parse my "if exist" statement and run that
> > > > separately. And I really don't want to shell out and use sol server
> > > > command
> > > > line tool.
> > > >
> > > > code snippet:
> > > > if exists (select * from dbo.sysobjects
> > > > where id = object_id(N'[dbo].[delete_datafeed_response]')
> > > > and OBJECTPROPERTY(id, N'IsProcedure') = 1)
> > > > drop procedure [dbo].[delete_datafeed_response]
> > > >
> > > > GO
> > > > create procedure [dbo].[delete_datafeed_response]
@day_delete_interval
> > int
> > > > as
> > > > begin
> > > >
> > > > Thanks
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
> >
>
>
- Next message: Jason Coyne Gaijin42: "Re: Using one instance of SqlConnection in an ASP.NET page"
- Previous message: CliffNews: "Re: Executing Stored Proc from file in Ado .NET"
- In reply to: Joe Fallon: "Re: Executing Stored Proc from file in Ado .NET"
- Next in thread: Joe Fallon: "Re: Executing Stored Proc from file in Ado .NET"
- Reply: Joe Fallon: "Re: Executing Stored Proc from file in Ado .NET"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|