• Paul White NZ (5/4/2010)


    Hugo Kornelis (5/4/2010)


    Here is another repro that runs fine on all clients, to demonstrate that SQL Server itself actually does not have any issues with this code:

    -- Or, the more direct approach

    SELECT CAST(ROUND(0.5,0) AS decimal(12,2));

    According to Jim Hogg (MSFT) on Connect, the error is raised by SQL Server, and is By Design:

    https://connect.microsoft.com/SQLServer/feedback/details/364387/using-round-function-with-passing-numeric-expression-to-9-5-and-length-0

    Good find, Paul.

    But Jim is wrong. If his explanation was correct, thanDECLARE @x numeric(2,1); SET @x = ROUND(9.5,0);should return an error, on all clients. It does not. ButDECLARE @x numeric(2,1); SET @x = ROUND(9.5,0); SELECT @x;does return an error, on some clients.


    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/