• honza.mf (12/14/2009)


    Christian Buettner-167247 (12/14/2009)


    Hm, is someone able to explain this?

    Same code as before, but positioned order by (1 instead of i) and "-" as separator for better readability.

    As said in explanation:

    The second construct is not documented, but works this same way on MS SQL Server 2000, 2005, and 2008.

    I don't know how the undocumented construct works. But there are another questions: What is the first column in your select? Is it OK to order on missing column?

    Hi Honza,

    I know it's not documented - I just would like to know if someone knows what is going on behind the scenes. I am just curious. My question was not meant to be a challenge for your QotD.

    But with regards to your question

    Is it OK to order on missing column?

    It "might" be OK, since SQL Server is not generating an error.

    But it might as well be not OK (to which I tend more)

    But take the "unsupported" SET statement from your QotD - is it OK to use it as it is? From a SQL standpoint it should not be valid, but obviously it seems to work and you can do some useful stuff with it.

    Now don't ask me for what you could use the positioned order by in my example - actually i just misread your example and exchanged the I with a 1 accidentially. Took me a while to figure out what I had done wrong...

    Best Regards,

    Chris Büttner