• Christian Buettner-167247 (5/4/2010)


    One important observation: This is an error caused within the client tool, not within SQL Server.

    Good observation, Christian. The format of the error message, which looks quite different from errors that are thrown by SQL Server, is also an indication that there is a different source of the error.

    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:

    DECLARE @a sql_variant;

    SET @a = ROUND(0.5,0);

    -- no error

    SELECT CAST(@a AS decimal(12,2));

    -- error when running on SSMS

    SELECT @a;

    go

    -- Or, the more direct approach

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

    go


    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/