September 13, 2018 at 6:50 am
andycadley - Thursday, September 13, 2018 12:53 AMLynn Pettis - Wednesday, September 12, 2018 3:56 PMThere is clearly still a long road to go before people default to learning the basics of structured programming before hacking the living daylights out of process flow with gotos.
Like anything else, GOTO can certainly be abused but, like anything else, it does have its uses.
--Jeff Moden
September 13, 2018 at 7:10 am
That may be Jeff but I have seen exactly zero times that a GOTO was needed since sql 2005 when they included TRY/CATCH. In my mind the GOTO is deprecated and should be replaced when encountered.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
September 13, 2018 at 7:15 am
If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.
September 13, 2018 at 7:22 am
September 13, 2018 at 8:21 am
Understood on all of that but it is a tool and if you ever need it, you would like it to be available.
I will admit that I've not used it for more than a decade and I don't remember the particulars of what I used it for but I do remember going through a peer review about it and getting my butt chewed for its use until the person doing the review finally understood why I was using it.
Just like Cursors and While loops, "It Depends" comes into play and there are uses for such things even if they only occur once or twice in a decade or two. 😀
--Jeff Moden
September 13, 2018 at 8:23 am
Shifting gears to TRY/CATCH, I think that the way a lot of people use it is wrong, especially in the presence of SET XACT_ABORT ON. Might be worth an article someday.
--Jeff Moden
September 13, 2018 at 9:35 am
Short why?
-------------------------------------------------------------------------------------------------------------------------------------
Please follow Best Practices For Posting On Forums to receive quicker and higher quality responses
September 13, 2018 at 11:40 am
jonathan.crawford - Thursday, September 13, 2018 9:35 AMShort why?
Sure but my system at work won't allow me to post what I need to explain and I won't be at home until about 10PM tonight. I'll try to post what I mean after that.
--Jeff Moden
September 13, 2018 at 11:44 am
OMG. I'm working on a stored procedure that references an EAV table and it has 73 separate subqueries in a single SELECT statement to pull values out of the EAV table. And that's only the most egregious example. It also references a couple of other EAV tables.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 13, 2018 at 11:57 am
drew.allen - Thursday, September 13, 2018 11:44 AMOMG. I'm working on a stored procedure that references an EAV table and it has 73 separate subqueries in a single SELECT statement to pull values out of the EAV table. And that's only the most egregious example. It also references a couple of other EAV tables.Drew
But it's fast, right? :D:D:D
--Jeff Moden
September 13, 2018 at 12:10 pm
Jeff Moden - Thursday, September 13, 2018 8:23 AMShifting gears to TRY/CATCH, I think that the way a lot of people use it is wrong, especially in the presence of SET XACT_ABORT ON. Might be worth an article someday.
The biggest problem i see people doing with TRY/CATCH and this isn't just in SQL Server is that people use it to do exactly what the guy in that post was doing. No attempt at pre parsing or correcting errors, just throw a bunch of stuff into it and see if it sticks. Which isn't so much an issue with TRY/CATCH itself, used properly it's very powerful and useful, it just enables some very lazy design practices.
September 13, 2018 at 1:12 pm
ZZartin - Thursday, September 13, 2018 12:10 PMThe biggest problem i see people doing with TRY/CATCH and this isn't just in SQL Server is that people use it to do exactly what the guy in that post was doing. No attempt at pre parsing or correcting errors, just throw a bunch of stuff into it and see if it sticks. Which isn't so much an issue with TRY/CATCH itself, used properly it's very powerful and useful, it just enables some very lazy design practices.
Agreed. That's a major part of the "abuse" of TRY/CATCH I've seen.
--Jeff Moden
September 13, 2018 at 1:25 pm
ZZartin - Thursday, September 13, 2018 12:10 PMJeff Moden - Thursday, September 13, 2018 8:23 AMShifting gears to TRY/CATCH, I think that the way a lot of people use it is wrong, especially in the presence of SET XACT_ABORT ON. Might be worth an article someday.The biggest problem i see people doing with TRY/CATCH and this isn't just in SQL Server is that people use it to do exactly what the guy in that post was doing. No attempt at pre parsing or correcting errors, just throw a bunch of stuff into it and see if it sticks. Which isn't so much an issue with TRY/CATCH itself, used properly it's very powerful and useful, it just enables some very lazy design practices.
Far too often it gets turned into a TRY/SQUELCH instead. They use crappy code to swallow errors.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
September 13, 2018 at 1:31 pm
Sean Lange - Thursday, September 13, 2018 1:25 PMFar too often it gets turned into a TRY/SQUELCH instead. They use crappy code to swallow errors.
Viewing 15 posts - 62,206 through 62,220 (of 66,000 total)
You must be logged in to reply to this topic. Login to reply