Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get SQL Server Management Studio to stop processing on an error?

This seems like an incredibly dumb question to have to ask, but how do I get SQL Server Management Studio to stop processing a SQL script when it encounters an error?

I have a long script and if there is an error at the start SSMS reports it and then blindly carries on, screwing up things even more. I can't use transactions because the script creates several databases and they can't go in a transaction. It is the database creation that sometimes fails.

Toad for SQL Server will pause at the first error it encounters and ask if you want to stop or continue. This is the behaviour I'm looking for. Does it exist in SSMS?

I am not asking, "How do I write or modify a script so that it stops on an error?" I'm not interested in modifying my script to make this happen, I just want SSMS to stop on an error. Toad for SQL Server does exactly this and that is the behaviour I want. This is also not a duplicate of 659188 because that relates to modifying the script to stop SSMS.

like image 931
TallGuy Avatar asked May 11 '09 00:05

TallGuy


People also ask

How do I stop a running process in SQL Server?

SQL Server Management Studio Activity Monitor Once Activity Monitor has loaded, expand the 'Processes' section. Scroll down to the SPID of the process you would like to kill. Right click on that line and select 'Kill Process'. A popup window will open for you to confirm that you want to kill the process.

How do I stop an executing query in SSMS?

Use KILL SPID command to eliminate blocking in SQL Server Execute the following query in SSMS session. The SPID for this session is 60. In another session, it tries to get records of the table. The SPID for this session is 83.


1 Answers

Short answer: You can't.

Thanks to those that provided workarounds, but it seems that SSMS itself can not be set to pause or stop on an error in the same way that Toad for SQL Server can.

like image 131
TallGuy Avatar answered Oct 06 '22 09:10

TallGuy