Home Forums SQL Server 2008 T-SQL (SS2K8) Getting undesirable trailing zeros after casting to decimal RE: Getting undesirable trailing zeros after casting to decimal

  • You have only shared a small piece of your code, so we need to guess.

    Is your code selecting into a table? i.e. Maybe the following code example will show what I mean.

    CREATE TABLE #Test (Value DECIMAL(15, 12));

    INSERT INTO #Test VALUES (123.759815009);

    SELECT * FROM #Test;

    DROP TABLE #Test;

    GO

    CREATE TABLE #Test (Value DECIMAL(15, 12));

    INSERT INTO #Test VALUES (CAST(123.759815009 AS DECIMAL(10, 2)));

    SELECT * FROM #Test;

    DROP TABLE #Test;

    GO

    CREATE TABLE #Test (Value DECIMAL(10, 2));

    INSERT INTO #Test VALUES (123.759815009);

    SELECT * FROM #Test;

    DROP TABLE #Test;

    GO

    The SQL Guy @ blogspot[/url]

    @SeanPearceSQL

    About Me[/url]