Hello I had a similar problem as original poster - needing to kill multiple
batches within the same script.
Raiserror is not working for me.
raiserror ('just kill me now',19,1, 'WITH LOG,NOWAIT')
comes back with
Server: Msg 2754, Level 16, State 1, Line 1
Error severity levels greater than 18 can only be specified by members of
the sysadmin role, using the WITH LOG option.
I am sure that the account i am using has the sysadmin fixed server role.
PLEASE HELP!
Thanks,
Joel Mariano
[quoted text, click to view] "Jacco Schalkwijk" wrote:
> There is no neat way to do this in Query Analyzer except raising an error
> with severity 20 or higher, which will terminate your connection:
> RAISERROR ('Your message here.', 20, 1)
> If you use osql to run a script, you can raise an error with a status of
> 127, which will have the same effect, but won't leave traces in the SQL
> Server error log like raising an error with status 20 does.
> RAISERROR ('Your message here.', 16, 127)
>
> --
> Jacco Schalkwijk
> SQL Server MVP
>
>
> "Greg Michalopoulos" <gmichalopoulos@d2hawkeye.com> wrote in message
> news:OYM9dqG5EHA.2600@TK2MSFTNGP09.phx.gbl...
> > Is there a SQL command which will kill or exit all batches in the query
> > analyzer?
> >
> > For example I have this script:
> >
> > query1
> > query2
> > GO
> > query3
> > query4
> > query5
> > GO
> >
> > Is there a way so that when I check @@ERROR after query1 that query2,3,4,5
> > do NOT get executed? GOTO's cannot see beyond the next GO.
> >
> > Thanks,
> > Greg
> >
>
>
Whoops, brain fart:
raiserror ('just kill me now',20,1) WITH LOG,NOWAIT
works just fine (drops the connection).
[quoted text, click to view] "Joel Mariano" wrote:
> Hello I had a similar problem as original poster - needing to kill multiple
> batches within the same script.
>
> Raiserror is not working for me.
>
> raiserror ('just kill me now',19,1, 'WITH LOG,NOWAIT')
>
> comes back with
> Server: Msg 2754, Level 16, State 1, Line 1
> Error severity levels greater than 18 can only be specified by members of
> the sysadmin role, using the WITH LOG option.
>
> I am sure that the account i am using has the sysadmin fixed server role.
>
> PLEASE HELP!
>
> Thanks,
> Joel Mariano
>
> "Jacco Schalkwijk" wrote:
>
> > There is no neat way to do this in Query Analyzer except raising an error
> > with severity 20 or higher, which will terminate your connection:
> > RAISERROR ('Your message here.', 20, 1)
> > If you use osql to run a script, you can raise an error with a status of
> > 127, which will have the same effect, but won't leave traces in the SQL
> > Server error log like raising an error with status 20 does.
> > RAISERROR ('Your message here.', 16, 127)
> >
> > --
> > Jacco Schalkwijk
> > SQL Server MVP
> >
> >
> > "Greg Michalopoulos" <gmichalopoulos@d2hawkeye.com> wrote in message
> > news:OYM9dqG5EHA.2600@TK2MSFTNGP09.phx.gbl...
> > > Is there a SQL command which will kill or exit all batches in the query
> > > analyzer?
> > >
> > > For example I have this script:
> > >
> > > query1
> > > query2
> > > GO
> > > query3
> > > query4
> > > query5
> > > GO
> > >
> > > Is there a way so that when I check @@ERROR after query1 that query2,3,4,5
> > > do NOT get executed? GOTO's cannot see beyond the next GO.
> > >
> > > Thanks,
> > > Greg
> > >
> >
> >
Don't see what you're looking for? Try a search.