SQL CHOOSE

  • james.of.rivendell (6/19/2013)


    None of the answers is correct. Choose is a 2012 function, so it doesn't work in 2008 R2, which is the *assumed* SQL version here. Nowhere in the question do I see an overriding statement to state the exception.

    Seriously?

    Anyway, thanks for the question, keep up the effort.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Best thing about this QOTD was a good example of the CHOOSE function.

    One of the Posts suggested that SQL Server 2008 R2 was the Default is interesting as I haven't seen this mentioned before. I do think that it wouldn't hurt for each QOTD to state which versions the Code was tested on.

    I'm still on 2008 R2 and looking forward to 2012. I haven't seen anything in the 2014 announcements to make this worth waiting for.

    David

  • David Conn (6/22/2013)


    One of the Posts suggested that SQL Server 2008 R2 was the Default is interesting as I haven't seen this mentioned before.

    I think I know where this come from. Often, when people complain that a question doesn't work as stated on their SQL2005 or SQL2000, they are told that when nothing is specified about the version, they can assume it to be at least SQL Server 2008, for that is the oldest version still in mainstream support.

    Note the words "at least" in the above. 🙂

    For this particular question, you could become technical and say that the version should have been specified because 2008 and 2008R2 are still supported and don't support CHOOSE. But since there is no answer option that would be correct for SQL 2008/2008R2, I think it's pretty obvious whaht the intention is. And I think that SQL 2012 is available long enough that people have had the chance to become acquainted with the new functions.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Danny Ocean (6/18/2013)


    Good question. But i think this question should had topic "DateTime" rather than "SQL CHOOSE". 🙂

    I think 'CHOOSE' is the correct topic. There was nothing particular about the dates (unless you couldn't spot that 1932 is a leap year) so I don't see how this is really a DateTime question. Just a shame we won't be moving to SQL 2012 anytime in the foreseeable future so I won't get to use CHOOSE.

  • Hugo Kornelis (6/19/2013)


    Never forget that making new errors is far more fun than repeating your old errors!

    I have a lot of fun nearly every day!

  • It was a perfect confusing act. I was almost going to wrong route by taking the PositionId as Months in the SELECT query. At the last moment saw the Birthday column being used inside.

    Good QOTD. 🙂

  • We can assume, though, that since none of the answers were "doesn't work in this version of SQL", that we would be using a version of SQL that does support that function.

    That is what I assumed when I got an error message about Choose with SQL 2008 R2. So I just changed the query a bit to:

    Select DateName(mm, BirthDay) from #Employee

    __________________________________________________________________________________________________________
    How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/

Viewing 7 posts - 31 through 36 (of 36 total)

You must be logged in to reply to this topic. Login to reply