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.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Deployment strategy

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

Posted - 2009-12-23 : 15:38:39
Why can't you use TRY/CATCH? It certainly simplifies error handling. Could you show us an example of what you are doing in the script?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2009-12-23 : 16:02:00
-- code segment 1
create 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
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-23 : 16:20:06
That isn't a valid example as you work out those kinks in a test environment. You certainly would not run a script like that with that blatant bug in production without first making sure the script is good.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -