I love my job.
I know I keep saying that... but I really do.
Today's SQL puzzler is this (if you think that you have a solution that is better PLEASE comment below):
I need a script that has multiple GOs, and if something goes wrong I need the ENTIRE script to cancel.
@somethingiswrong = 1
if @somethingiswrong = 1
--code needs to exit here
--this is a new batch. this should not execute
'i should not be here'
I went though a couple of iterations, including
'Oh no a fatal error'
, 20, -1)
Which was brutally heavy handed, and
Which... was interesting, and it worked... but I wasn't sold.
I ended up with this: