If you are talking about presenting the result and using MS SQL Server 2012 or higher, you can use the FORMAT
function to determine the number of houses after the comma, like this:
select format(1234.5678, '#.000')
The result will be 1234.568
(see that it has been rounded).
And, to display without any decimal places:
select format(1234.5678, '#')
The result will be 1235
(also rounded).
Update: In earlier versions, you can use the ROUND
:
select round(1234.5678, 3)
select round(1234.5678, 0)
Results: 1234.568
and 1235
.
Or you can convert the value to DECIMAL
by limiting the number of decimal places:
select cast(1234.5678 as decimal(10, 3))
select cast(1234.5678 as decimal(10, 0))
Results: also 1234.568
and 1235
.
At your command, simply apply the chosen method on each column resulting from the SELECT command. For example:
SELECT
rtrim(name)as name,
ROUND(((size)/128.0), 3) as'size in MB',
ROUND(((size)/128.0) -CAST(FILEPROPERTY(name,'SpaceUsed')AS int)/128.0, 3)
AS AvailableSpaceInMB,
ROUND(((((size)/128.0)
-CAST(FILEPROPERTY(name,'SpaceUsed') AS int)/128.0)
/((size)/128.0)) * 100, 0) as'% Available',
filename
FROM
sysfiles