By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,230 Members | 2,471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,230 IT Pros & Developers. It's quick & easy.

Stopping a script

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.