• archie flockhart (11/23/2011)


    In the BOL, I still don't see anything that goes beyond "for some reason" as an explanation of why you can't convert an empty string to decimal, while you can convert it to integer or float or bit.

    L' Eomot Inversé (11/23/2011)


    That explicit documentation doesn't give any explanation either.

    Apparently, I didn't make myself sufficiently clear.

    It's true that Books Online doesn't explain WHY SQL Server behaves this way. But that is true of a lot, probably almost all, articles in Books Online. Why is an integer stored in 4 bytes? Why is INTO optional in the INSERT statement? Why is EXEC[UTE] optional at the start of a batch but mandatory at other places? Some of these will have very good reasons, others maybe not. But the point is that they are all documented.

    In a question of the day, I think the explanation should make clear why the given answer is correct. Not "why" as in "why did the SQL Server team make it this way", but "why" as in "what documented feature (*) causes this effect"? That's what I was missing in the explanation. The link to the CAST and CONVERT article would have provided that explanation, as this article clearly documents that this is intended behaviour.


    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/