Display GB vs kb in SELECT statement ??

  • Hi,

    I've created some code that captures filesize using sp_helpfile. The column (filesize_kb) that stores the filesize portion datatype int (representing kb). Any suggestions on how to format the display in a SELECT statement to represent GB vs kb?

    saved in db: 13451584

    would like displayed 13.451584 or rounded 3 decimal places ... 13.452

    I tried filesize_kb/1000000, but it rounds & truncates other digits ie: 13 is displayed ... i would like to keep the other digits ie: just move the decimal place.

    Many thanks. Jeff

  • Select Cast(filesize_kb As float) / 1000000.0

    To get 3 decimal places, cast result to a numeric:

    Select Cast(  (Cast(filesize_kb As float) / 1000000.0) As Numeric(12,3) )

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

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