Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
ravilobo
Master Smack Fu Yak Hacker
1184 Posts |
Posted - 2009-12-23 : 15:34:38
|
I have a lengthy SQL code that needs to be deployed to the prod. While at execution, If the code encounters error, further execution should stop. 1. I don’t (and can’t) want to put the whole thing in a giant TRY/CATCH 2. I can use RAISERROR with severity greater than 19 which will disconnect the DB connection. (This is a bit crude option)Is there a better way?------------------------I think, therefore I am - Rene Descartes |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
ravilobo
Master Smack Fu Yak Hacker
1184 Posts |
Posted - 2009-12-23 : 16:02:00
|
-- code segment 1create table t1 (col1 int,col1 int)GO .....-- code segment 50 create table t2 (col2 int)GO Above is my example. All the sql code blocks are in one single script seperated by GO. Code segment 1 has an error (duplicate column). My requirement is when the first error occurs, further execution should stop. In my case table t2 gets created; I don't want that. ------------------------I think, therefore I am - Rene Descartes |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|