percentage format question in T-SQL

  • Hello All,

    What would be the best approach to tackle the following:

    I am getting a number from Database. I need to format it so  it would appear as percentage.

    Ex: if I get 58 then it should look like 5.80

         if I get 120 then it should look like 12.00

         if  I get 5 then it should look like 0.50.

    I am using SQL 7, so  I cannot use UDF. (And I cannot format it on the front end)

    I feel that  I need to write a lot of Case statements??..

    Please let me know.

  • convert or cast in decimal data type.

    something like convert(decimal(6,2), column/10.0)

  • Use will work and is considered better syntax than convert. Same thing basically thou.

     

    CAST((value / 10.0) AS NUMERIC(10,2))

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

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