January 12, 2013 at 12:32 pm
Comments posted to this topic are about the item T-SQL 2012 #2
January 12, 2013 at 12:41 pm
Nice clear straightforward question.
Good to see a question on this new feature.
Interestingly, there's an error on the BoL page: it says the CHOOSE function
BoL
Returns the data type with the highest precedence from the set of types passed to the function
The first argument is an integer, which has a higher type precedence than any character type, but if it really was going to return an int we would have string to int conversion errors here. BoL should instead say that the return type is highest precedence type of the arguments other than the first.
Tom
January 12, 2013 at 1:45 pm
L' Eomot Inversé (1/12/2013)
Nice clear straightforward question.Good to see a question on this new feature.
Interestingly, there's an error on the BoL page: it says the CHOOSE function
BoL
Returns the data type with the highest precedence from the set of types passed to the functionThe first argument is an integer, which has a higher type precedence than any character type, but if it really was going to return an int we would have string to int conversion errors here. BoL should instead say that the return type is highest precedence type of the arguments other than the first.
From the supporting link in the question
CHOOSE acts like an index into an array, where the array is composed of the arguments that follow the index argument. The index argument determines which of the following values will be returned.
January 12, 2013 at 5:18 pm
Glad we have this feature added.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
January 12, 2013 at 6:25 pm
bitbucket-25253 (1/12/2013)
L' Eomot Inversé (1/12/2013)
Nice clear straightforward question.Good to see a question on this new feature.
Interestingly, there's an error on the BoL page: it says the CHOOSE function
BoL
Returns the data type with the highest precedence from the set of types passed to the functionThe first argument is an integer, which has a higher type precedence than any character type, but if it really was going to return an int we would have string to int conversion errors here. BoL should instead say that the return type is highest precedence type of the arguments other than the first.
From the supporting link in the question
CHOOSE acts like an index into an array, where the array is composed of the arguments that follow the index argument. The index argument determines which of the following values will be returned.
Yes, it says that. But that says nothing about the type returned, it's about which value is selected before any necessary type conversion is done. The same page contains the incorrect statement that I quoted, which says nothing about which value is selected, only about which type it is to be converted to (which it gets wrong).
Tom
January 13, 2013 at 10:16 pm
Wow.. Thanks Ron for another one on SS2012 🙂
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
January 13, 2013 at 10:27 pm
Lokesh Vij (1/13/2013)
Wow.. Thanks Ron for another one on SS2012 🙂
+1
Thanks for the question..
~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one :ermm:
January 14, 2013 at 12:05 am
This was removed by the editor as SPAM
January 14, 2013 at 12:06 am
Thanks a lot for this question. Got to know about CHOOSE function. Very helpful. 🙂
January 14, 2013 at 1:28 am
Great question about a new 2012 feature. Thanks Ron!
(and thanks for including me ;-))
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
January 14, 2013 at 6:32 am
Good introduction the CHOOSE function.
January 14, 2013 at 7:23 am
Great question about a new feature.
January 14, 2013 at 7:30 am
What would be a good use of this function?
Why wouldn't you just add a lookup table containing the index and description, and join to that?
So that any changes required to a description could be made by just updating the lookup table, rather than rewriting SQL.
January 14, 2013 at 7:46 am
Thanks for the question.
Viewing 15 posts - 1 through 15 (of 31 total)
You must be logged in to reply to this topic. Login to reply