T-SQL

  • Good question, though not the first time I have seen it.

    The explanation can be improved. What happens is that ISNULL is defined as returning the same data type as the first argument. Whereas the (otherwise mostly similar, but more portable and more flexible) alternative keyword COALESCE uses the standard rules of data type preference between all arguments passed in.


    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/

  • SALIM ALI (12/19/2014)


    the answer is only correct when using SqlServer 2012 and above. Previous versions prompt an error.

    That`s not correct, as SQL 2k8 will work fine with the in-line assignement.

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • Nice question, thanks.

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

  • A nice question. But a shame that 'SQL String' wasn't an option, and that there was no reference as to what happens when you assign a value longer than the definition (ie it truncates it rather than raising an error).

  • Very Tricky.. Learning Lot.

  • Thanks for the question.

  • Toreador (12/22/2014)


    A nice question. But a shame that 'SQL String' wasn't an option, and that there was no reference as to what happens when you assign a value longer than the definition (ie it truncates it rather than raising an error).

    +1

    Literally exactly what I was going to say.

Viewing 7 posts - 16 through 23 (of 23 total)

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