• A good and creative question, hampered by some flaws in the explanation.

    The reason the number 2 is converted to bit 1 is not because of its bit pattern, but for the simple reason that "Converting to bit promotes any nonzero value to 1." (see http://msdn.microsoft.com/en-us/library/ms177603.aspx).

    Other than that, the explanation itself was okay, but I don't understand (1) why the same reference was included three times - -was this supposed to be three different references? If not, including it once would have been better for readability; and (2) why the references are all to an outdated version of Books Online (the "(v=SQL.90)" at the end of the link force Books Online to show the SQL 2005 version; similarly, you can use (v=SQL.100), (v=SQL.105), or (v=SQL.110) for the SQL2008, SQL2008R2, and SQL2012 version -provided the same page exists in that version. Or, my recommendation, you can leave out the version completely and always get the version from the most current Books Online.

    (The last remark is targeted at all QotD authors, not just Thomas - it keeps surprising me how many questions inlcude references to old versions, and I never understand why people don't bother to link to a more recent version).


    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/