Converting Numeric to Decimal in T-SQL

  • I have to columns that performs sums. However I want the specific data type to be decimal with two decimal places, and not numeric. I've tried to use Convert (decimal (9,2), etc..., but I have to get it to work. I know it's something simple that I'm overlooking. Help please.

    Current Code:

    SELECT [Workstation Count], 100.00 * ([Total Installed] / [Total Events]) AS Installed, 100.00 * ([Total Missing] / [Total Events]) AS Missing

    FROM dbo.CR_Cook_Wksta_Cnt

  • rjshupert (11/18/2008)


    I have to columns that performs sums. However I want the specific data type to be decimal with two decimal places, and not numeric. I've tried to use Convert (decimal (9,2), etc..., but I have to get it to work. I know it's something simple that I'm overlooking. Help please.

    Current Code:

    SELECT [Workstation Count], 100.00 * ([Total Installed] / [Total Events]) AS Installed, 100.00 * ([Total Missing] / [Total Events]) AS Missing

    FROM dbo.CR_Cook_Wksta_Cnt

    Try:

    SELECT [Workstation Count], 100.00 * (1.0*[Total Installed] / [Total Events]) AS Installed, 100.00 * (1.0*[Total Missing] / [Total Events]) AS Missing

    FROM dbo.CR_Cook_Wksta_Cnt[/quote]


    * Noel

  • Good solution NoelD.

  • Thanks,

    That still didn't work, it still is numeric.

Viewing 4 posts - 1 through 3 (of 3 total)

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