February 27, 2009 at 10:18 am
Hi,
I have a script worth 1000 lines which creates DB & other many objects. I am using TRY CATCH & RAISERROR in my stored proc to trap the errors.
Problem is if it fails in between -- it does give me the error message but continues to execute after that particular GO statement and other objects are getting created. I want the script to stop right there and dont continue further. Can anyone suggest me a way to do this?
Idont want to use Error Severity of 21 which will disconnect the connection.
Thanks in advance...
February 27, 2009 at 10:23 am
in SSMS or Query analyzer, you can't...as you identified, the GO statements start a new batch, and you can't interupt the processing of the batches without raising an error severity 21 or so;
you could wite a quick and dirty application that runs the sql file, grabbing each section delimited by GO, and stip it's execution if .ExecuteNonQuery returns an exception for example.
but i don't think that's what you were looking for.
Lowell
March 3, 2009 at 7:57 pm
Heh... why can't you just remove the GO's?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply