470,870 Members | 1,475 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,870 developers. It's quick & easy.

Stopping a script

In query analyser, I can stop a script with the "return" statement but
if the script contains multiple batches (separated by GO) then the
return statement only stops the current batch.

Is there a way to stop the whole script?

Jul 23 '05 #1
2 1566
If you are a sysadmin you can kill the current process with RAISERROR:

RAISERROR('Kill Process',20,1) WITH LOG

--
David Portas
SQL Server MVP
--

Jul 23 '05 #2
Trevor Best (go**********@besty.org.uk) writes:
In query analyser, I can stop a script with the "return" statement but
if the script contains multiple batches (separated by GO) then the
return statement only stops the current batch.

Is there a way to stop the whole script?


In additions to David's brutal suggestion, there is another way,
although in only works in the command-tool OSQL, not in Query
Analyer.

In OSQL you can do a RAISERROR with state 127:

RAISERROR('Quitting OSQL', 0, 127)

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

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Bart Nessux | last post: by
6 posts views Thread by Dave | last post: by
23 posts views Thread by ern | last post: by
4 posts views Thread by Nick Wedd | last post: by
6 posts views Thread by Andrew Poulos | last post: by
4 posts views Thread by Jeff | last post: by
6 posts views Thread by naurus | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.