November 9, 2018 at 11:24 am
I just want to be 100% sure... Do the following two statements execute identically? Meaning, can I use the 2nd one, or do I need the extra BEGIN/END as in the 1st one? Thanks!
IF @blabla > 0
BEGIN
BEGIN TRY
[do lotsa stuff]
END TRY
BEGIN CATCH
[do stuff]
END CATCH
END
IF @blabla > 0
BEGIN TRY
[do lotsa stuff]
END TRY
BEGIN CATCH
[do stuff]
END CATCH
November 9, 2018 at 11:58 am
Try them both and see if either or both work. Personally, I would lean to using the first format because of the IF.
November 9, 2018 at 1:24 pm
As far as I can tell, it seems to work the same either way. Just didn't want to accidentally screw this up.
November 9, 2018 at 2:33 pm
autoexcrement - Friday, November 9, 2018 1:24 PMAs far as I can tell, it seems to work the same either way. Just didn't want to accidentally screw this up.
If you are working in a development or sandbox environment you should screw anything up that can't be fixed. Don't test in production.
November 10, 2018 at 4:45 am
Both will work, though I personally prefer the explicit BEGIN/END pair on any IF statement, if only because somebody will come along later and ask the same question about whether that works or not.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply