February 17, 2010 at 5:55 am
T-SQL Coding - How do you code error handling logic in your SQL Server stored procedures?
February 17, 2010 at 5:58 am
^^^^ R a j u ^^^ (2/17/2010)
T-SQL Coding - How do you code error handling logic in your SQL Server stored procedures?
Bug-free, naturally 🙂
April 21, 2015 at 12:57 pm
Input parameter validation and TRY...CATCH blocks are a great start
April 21, 2015 at 2:55 pm
It's a good idea to do some logging when an error are detected, as well as trying to recover or contain the error.
And of course code defensively (detect the impossible happening and deal with it), and (paraphrasing Paul) correctly.
Tom
April 21, 2015 at 6:38 pm
LOL! A 5 year old thread?
Well, since you brought it up, this is how I do it.
Logging and Error Handling for SQL Stored Procedures [/url]
My thought question: Have you ever been told that your query runs too fast?
My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]
[url url=http://www.sqlservercentral.com/articles/St
April 21, 2015 at 10:39 pm
I find that many people don't actually know how to write Try/Catch. What they end up doing is throwing the same error but in a manner that obfuscates where the problem actually occurred.
I also agree with Paul White. Write code that won't fail whenever possible. 🙂
--Jeff Moden
Change is inevitable... Change for the better is not.
April 21, 2015 at 11:29 pm
Jeff Moden (4/21/2015)
I also agree with Paul White. Write code that won't fail whenever possible. 🙂
Me too! Makes testing a whole lot simpler and quicker!
My thought question: Have you ever been told that your query runs too fast?
My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]
[url url=http://www.sqlservercentral.com/articles/St
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply