January 15, 2013 at 8:51 pm
Comments posted to this topic are about the item TRY...CATCH
January 15, 2013 at 8:52 pm
Easy one for the day. Thanks 🙂
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
January 15, 2013 at 10:22 pm
for missing explanation ; I think Funtion is designed to return a value . When error handling is allowed , suppose an exception is raised , the return value is bound to restrictions . That may have been the reason to not allow the try catch handling in sql server.
please correct me if I am wrong.
~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one :ermm:
January 15, 2013 at 11:54 pm
Good question brushin up your skills. 🙂
January 16, 2013 at 12:44 am
Nice question, thanks! Explanation is short, but correct 😀
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
January 16, 2013 at 12:46 am
Nice and straightforwards - thanks
-------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
I would never join a club that would allow me as a member - Groucho Marx
January 16, 2013 at 1:25 am
Good question. I had to do a bit of research - I knew it wasn't allowewd in inline functions, but was unsure about multi-statement and scalar functions.
The link provided in the explanation is for SQL Server 2005; here are two links for the current version:
http://msdn.microsoft.com/en-us/library/ms175976.aspx
http://msdn.microsoft.com/en-us/library/ms186755.aspx
January 16, 2013 at 1:41 am
Ouch - read this too quickly and 'saw' cannot as can...
January 16, 2013 at 2:55 am
Nice question, good to remember.
I'm struggling to think what you'd be doing in a function that would require a TRY... CATCH 🙂
January 16, 2013 at 3:03 am
Gazareth (1/16/2013)
I'm struggling to think what you'd be doing in a function that would require a TRY... CATCH 🙂
Data conversions with possibly unclean data; computations that could generate an overflow, underflow, or divide by zero condition, etc.
Or maybe even lookups in a table that might not exist (I shudder at the thought of having to maintain a database where that is a serious possibility - but I've seen worse)
January 16, 2013 at 3:56 am
Hugo Kornelis (1/16/2013)
Gazareth (1/16/2013)
I'm struggling to think what you'd be doing in a function that would require a TRY... CATCH 🙂Data conversions with possibly unclean data; computations that could generate an overflow, underflow, or divide by zero condition, etc.
Or maybe even lookups in a table that might not exist (I shudder at the thought of having to maintain a database where that is a serious possibility - but I've seen worse)
Fair enough, although I'm not sure I personally would be using functions for most of those; and if I did I would probably be using other methods than TRY... CATCH to deal with them.
But that's just me. 🙂
January 16, 2013 at 5:05 am
Thanks for the great question. Had to research it to get it right.
January 16, 2013 at 5:49 am
negative questions make true to be false and vice versa... should've double read an easy question :Whistling:
January 16, 2013 at 5:53 am
nice question 🙂
Thanks&Regards
AJAY REDDY.L
January 16, 2013 at 6:08 am
I just encountered this scenario this past week. The ISDATE() and ISNUMERIC() functions are practically useless when determining whether a string will safely convert to a datetime or numeric value, respectively. (For example, '$' passes ISNUMERIC().) So I figured why not put a TRY...CATCH in a function, try to convert the value, return 0 if it fails and 1 if it doesn't. Bingo, working ISDATE(). But no... denied. Oh well.
ron
-----
a haiku...
NULL is not zero
NULL is not an empty string
NULL is the unknown
Viewing 15 posts - 1 through 15 (of 28 total)
You must be logged in to reply to this topic. Login to reply