• The question is strange, and the answer is wrong.

    "If an ELSE path is not provided in a CASE statement, the value it returns is NULL, not the initial value of the column or expression."

    Absolutely tryue (and not vague at all). But not proven by this question. Since @x was not initialized before the SET with the CASE expression, the initial value was NULL, and the code does not enable us to see that it is actually set to NULL and not left unchanged.

    The distracters are weird. The last option (NULL) is the only one that at least makes some sense. The second option (1) would have been more believable if it was presented as "@X is now 1<". As for the first option - where would this p come from? I have no idea what reasoning could lead people to believe that this answer can be correct.

    And the actual answer is "@X is now A<". That's because the author uses ISNULL instead of the recommended COALESCE. ISNULL does not follow the normal data type precedence rules, but always returns the data type of the first argument. In this case, @X is the first argument, and @X is char(1) - so the result of ISNULL is 'A' ('A NULL' converted / truncated to char(1).)


    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/