T-SQL 2012 #2

  • Comments posted to this topic are about the item T-SQL 2012 #2

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • 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

  • 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 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.

    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.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • 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

  • 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 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.

    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

  • Wow.. Thanks Ron for another one on SS2012 🙂

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • 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:

  • This was removed by the editor as SPAM

  • Thanks a lot for this question. Got to know about CHOOSE function. Very helpful. 🙂

  • 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

  • Thanks for a Monday question, that still made me learn something.

    [font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
    Connect to me on LinkedIn

  • Good introduction the CHOOSE function.

  • Great question about a new feature.



    Everything is awesome!

  • 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.

  • 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