Wednesday, March 28, 2012

QUERY PROBLEM

I have loaded disk drive information by computername in a SQL DB. I am
interested in Freespace. When the data is loaded into DB its in (K). How can
I display the freespace in MB?
Query:
select SystemName,Win32_DiskDrive_Model,Win32_L
ogicalDisk_FreeSpace from
SystemInfo
The result is the following:
SystemName Drive Model FreeSpace
posdtdc368900 ST320410A 18982992896
I want to display FreeSpace in MB. I know that taking freeSpace and dividing
by 1048576 will give me MB. Just do not know how divide with TSQL.
The next step once converted to mb is to add a clause to get any drives less
than 500mb.select SystemName,Win32_DiskDrive_Model,Win32_L
ogicalDisk_FreeSpace/1048576
AS [Free Space (MB)]
from SystemInfo
Jacco Schalkwijk
SQL Server MVP
"Big D" <BigDaddy@.newsgroup.nospam> wrote in message
news:OYpv7T6aFHA.1660@.tk2msftngp13.phx.gbl...
>I have loaded disk drive information by computername in a SQL DB. I am
>interested in Freespace. When the data is loaded into DB its in (K). How
>can I display the freespace in MB?
>
> Query:
> select SystemName,Win32_DiskDrive_Model,Win32_L
ogicalDisk_FreeSpace from
> SystemInfo
>
> The result is the following:
> SystemName Drive Model FreeSpace
> posdtdc368900 ST320410A 18982992896
>
> I want to display FreeSpace in MB. I know that taking freeSpace and
> dividing by 1048576 will give me MB. Just do not know how divide with
> TSQL.
>
> The next step once converted to mb is to add a clause to get any drives
> less than 500mb.
>
>|||Try this
Select SystemName,Win32_DiskDrive_Model,Win32_L
ogicalDisk_FreeSpace/1048576
AS [Free Space (MB)]
From SystemInfo
Where (Win32_LogicalDisk_FreeSpace/1048576) < 500
"Big D" <BigDaddy@.newsgroup.nospam> escribi en el mensaje
news:OYpv7T6aFHA.1660@.tk2msftngp13.phx.gbl...
>I have loaded disk drive information by computername in a SQL DB. I am
>interested in Freespace. When the data is loaded into DB its in (K). How
>can I display the freespace in MB?
>
> Query:
> select SystemName,Win32_DiskDrive_Model,Win32_L
ogicalDisk_FreeSpace from
> SystemInfo
>
> The result is the following:
> SystemName Drive Model FreeSpace
> posdtdc368900 ST320410A 18982992896
>
> I want to display FreeSpace in MB. I know that taking freeSpace and
> dividing by 1048576 will give me MB. Just do not know how divide with
> TSQL.
>
> The next step once converted to mb is to add a clause to get any drives
> less than 500mb.
>
>

No comments:

Post a Comment