我有一些SQL查詢輸出用於磁盤空間不足。它以MB顯示,例如1342 MB轉換SQL中的數字
我想將其轉換爲GB,並且如果可能的話使用十進制格式,例如1.3 GB。有什麼建議麼?
編輯:我正在使用MS SQL 2008.而且我應該在原始文章中給出更多信息。抱歉。這是Lansweeper的報告。以下是當前的報告查詢。
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetUnique,
tsysOS.OSname As [OS Name],
tblAssets.Description,
tblDiskdrives.Caption As [Partition],
Cast(Cast(tblDiskdrives.Freespace As bigint)/1024/1024 As numeric) As
[Free (in MB)],
Cast(Cast(tblDiskdrives.Size As bigint)/1024/1024 As numeric) As
[Total Size (in MB)],
tblDiskdrives.Lastchanged As [last changed],
tsysOS.Image As icon
From tblAssets
Inner Join tblDiskdrives On tblAssets.AssetID = tblDiskdrives.AssetID
Inner Join tblOperatingsystem
On tblAssets.AssetID = tblOperatingsystem.AssetID
Inner Join tblComputersystem On tblAssets.AssetID = tblComputersystem.AssetID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysOS On tblAssets.OScode = tsysOS.OScode
Where Cast(Cast(tblDiskdrives.Freespace As bigint)/1024/1024 As numeric) <
5120 And Cast(Cast(tblDiskdrives.Size As bigint)/1024/1024 As numeric) <>
0 And tblComputersystem.Domainrole > 1 And tblDiskdrives.DriveType = 3 And
tblAssetCustom.State = 1
把它除以1024?你可能想要指定你正在使用的數據庫。 – sstan