﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / getting total disk space / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 09:24:03 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: getting total disk space</title><link>http://www.sqlservercentral.com/Forums/Topic1409804-391-1.aspx</link><description>Did you try this ?[code="sql"]SELECT distinct       vs.volume_mount_point      , vs.volume_id      , vs.logical_volume_name      , vs.file_system_type      , vs.total_bytes / 1048576 AS 'MBTotal'      , vs.available_bytes / 1048576 AS 'MBAvailable'      , CAST( 1.00 * vs.available_bytes / vs.total_bytes * 100 as decimal(5,2) ) as pctFree      , vs.supports_compression      , vs.supports_alternate_streams      , vs.supports_sparse_files      , vs.is_read_only      , vs.is_compressedFROM    [sys].[master_files] AS fCROSS APPLY [sys].[dm_os_volume_stats]([f].[database_id], [f].[file_id]) AS vsORDER BY [vs].[logical_volume_name] ;[/code]Of course, this will only provide information about drives to which the sqlinstance has databases allocated.</description><pubDate>Tue, 29 Jan 2013 06:58:10 GMT</pubDate><dc:creator>ALZDBA</dc:creator></item><item><title>RE: getting total disk space</title><link>http://www.sqlservercentral.com/Forums/Topic1409804-391-1.aspx</link><description>One really good powershell script is one a colleague sent me that emails me total disk space and free disk space for all servers listed in a text file:-Have a look :-)# First lets create a text file, where we will later save the freedisk space info$freeSpaceFileName = "&amp;lt;LOCATION&amp;gt;"$serverlist = "&amp;lt;LOCATION&amp;gt;\Servers.txt"$warning = 20$critical = 10$date = Get-Date -format dNew-Item -ItemType file $freeSpaceFileName -Force# Getting the freespace info using WMI#Get-WmiObject win32_logicaldisk | Where-Object {$_.drivetype -eq 3} | format-table DeviceID, VolumeName,status,Size,FreeSpace | Out-File FreeSpace.txt# Function to write the HTML Header to the fileFunction writeHtmlHeader{param($fileName)$date = Get-Date -format dAdd-Content $fileName "&amp;lt;html&amp;gt;"Add-Content $fileName "&amp;lt;head&amp;gt;"Add-Content $fileName "&amp;lt;meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'&amp;gt;"Add-Content $fileName '&amp;lt;title&amp;gt; $Date DiskSpace Report&amp;lt;/title&amp;gt;'add-content $fileName '&amp;lt;STYLE TYPE="text/css"&amp;gt;'add-content $fileName "&amp;lt;!--"add-content $fileName "td {"add-content $fileName "font-family: Tahoma;"add-content $fileName "font-size: 11px;"add-content $fileName "border-top: 1px solid #999999;"add-content $fileName "border-right: 1px solid #999999;"add-content $fileName "border-bottom: 1px solid #999999;"add-content $fileName "border-left: 1px solid #999999;"add-content $fileName "padding-top: 0px;"add-content $fileName "padding-right: 0px;"add-content $fileName "padding-bottom: 0px;"add-content $fileName "padding-left: 0px;"add-content $fileName "}"add-content $fileName "body {"add-content $fileName "margin-left: 5px;"add-content $fileName "margin-top: 5px;"add-content $fileName "margin-right: 0px;"add-content $fileName "margin-bottom: 10px;"add-content $fileName ""add-content $fileName "table {"add-content $fileName "border: thin solid #000000;"add-content $fileName "}"add-content $fileName "--&amp;gt;"add-content $fileName "&amp;lt;/style&amp;gt;"Add-Content $fileName "&amp;lt;/head&amp;gt;"Add-Content $fileName "&amp;lt;body&amp;gt;"add-content $fileName "&amp;lt;table width='100%'&amp;gt;"add-content $fileName "&amp;lt;tr bgcolor='#CCCCCC'&amp;gt;"add-content $fileName "&amp;lt;td colspan='7' height='25' align='center'&amp;gt;"add-content $fileName "&amp;lt;font face='tahoma' color='#003399' size='4'&amp;gt;&amp;lt;strong&amp;gt;DiskSpace Report - $date&amp;lt;/strong&amp;gt;&amp;lt;/font&amp;gt;"add-content $fileName "&amp;lt;/td&amp;gt;"add-content $fileName "&amp;lt;/tr&amp;gt;"add-content $fileName "&amp;lt;/table&amp;gt;"}# Function to write the HTML Header to the fileFunction writeTableHeader{param($fileName)Add-Content $fileName "&amp;lt;tr bgcolor=#CCCCCC&amp;gt;"Add-Content $fileName "&amp;lt;td width='10%' align='center'&amp;gt;Drive&amp;lt;/td&amp;gt;"Add-Content $fileName "&amp;lt;td width='50%' align='center'&amp;gt;Drive Label&amp;lt;/td&amp;gt;"Add-Content $fileName "&amp;lt;td width='10%' align='center'&amp;gt;Total Capacity(GB)&amp;lt;/td&amp;gt;"Add-Content $fileName "&amp;lt;td width='10%' align='center'&amp;gt;Used Capacity(GB)&amp;lt;/td&amp;gt;"Add-Content $fileName "&amp;lt;td width='10%' align='center'&amp;gt;Free Space(GB)&amp;lt;/td&amp;gt;"Add-Content $fileName "&amp;lt;td width='10%' align='center'&amp;gt;Freespace %&amp;lt;/td&amp;gt;"Add-Content $fileName "&amp;lt;/tr&amp;gt;"}Function writeHtmlFooter{param($fileName)Add-Content $fileName "&amp;lt;/body&amp;gt;"Add-Content $fileName "&amp;lt;/html&amp;gt;"}Function writeDiskInfo{param($fileName,$devId,$volName,$frSpace,$totSpace)$totSpace=[math]::Round(($totSpace/1073741824),2)$frSpace=[Math]::Round(($frSpace/1073741824),2)$usedSpace = $totSpace - $frspace$usedSpace=[Math]::Round($usedSpace,2)$freePercent = ($frspace/$totSpace)*100$freePercent = [Math]::Round($freePercent,0) if (($freePercent -le $warning) -and ($FreePercent -gt $critical)) { Add-Content $fileName "&amp;lt;tr&amp;gt;" Add-Content $fileName "&amp;lt;td align=center&amp;gt;$devid&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;td align=center&amp;gt;$volName&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;td align=center&amp;gt;$totSpace&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;td align=center&amp;gt;$usedSpace&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;td align=center&amp;gt;$frSpace&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;td bgcolor='#FFE600' align=center&amp;gt;$freePercent&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;/tr&amp;gt;" } elseif ($freePercent -le $critical) { Add-Content $fileName "&amp;lt;tr&amp;gt;" Add-Content $fileName "&amp;lt;td align=center&amp;gt;$devid&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;td align=center&amp;gt;$volName&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;td align=center&amp;gt;$totSpace&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;td align=center&amp;gt;$usedSpace&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;td align=center&amp;gt;$frSpace&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;td bgcolor='#FF0000' align=center&amp;gt;$freePercent&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;/tr&amp;gt;" } else { Add-Content $fileName "&amp;lt;tr&amp;gt;" Add-Content $fileName "&amp;lt;td align=center&amp;gt;$devid&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;td align=center&amp;gt;$volName&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;td align=center&amp;gt;$totSpace&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;td align=center&amp;gt;$usedSpace&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;td align=center&amp;gt;$frSpace&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;td align=center&amp;gt;$freePercent&amp;lt;/td&amp;gt;" Add-Content $fileName "&amp;lt;/tr&amp;gt;" }}Function sendEmail{ param($from,$to,$subject,$smtphost,$htmlFileName)$body = Get-Content $htmlFileName$smtp= New-Object System.Net.Mail.SmtpClient $smtphost$msg = New-Object System.Net.Mail.MailMessage $from, $to, $subject, $body$msg.isBodyhtml = $true$smtp.send($msg)}writeHtmlHeader $freeSpaceFileNameforeach ($server in Get-Content $serverlist){ Add-Content $freeSpaceFileName "&amp;lt;table width='100%'&amp;gt;&amp;lt;tbody&amp;gt;" Add-Content $freeSpaceFileName "&amp;lt;tr bgcolor='#CCCCCC'&amp;gt;" Add-Content $freeSpaceFileName "&amp;lt;td width='100%' align='center' colSpan=6&amp;gt;&amp;lt;font face='tahoma' color='#003399' size='2'&amp;gt;&amp;lt;strong&amp;gt; $server &amp;lt;/strong&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/td&amp;gt;" Add-Content $freeSpaceFileName "&amp;lt;/tr&amp;gt;" writeTableHeader $freeSpaceFileName $dp = Get-WmiObject win32_logicaldisk -ComputerName $server | Where-Object {$_.drivetype -eq 3} foreach ($item in $dp) { Write-Host $item.DeviceID $item.VolumeName $item.FreeSpace $item.Size writeDiskInfo $freeSpaceFileName $item.DeviceID $item.VolumeName $item.FreeSpace $item.Size}Add-Content $freeSpaceFileName "&amp;lt;/table&amp;gt;"}writeHtmlFooter $freeSpaceFileName$date = Get-Date -format dsendEmail &amp;lt;SENDER EMAIL ADDRESS&amp;gt; &amp;lt;RECIPIENT EMAIL ADDRESS&amp;gt; "Disk Space Report - $Date" &amp;lt;SMTP SERVER&amp;gt; $freeSpaceFileName</description><pubDate>Tue, 29 Jan 2013 06:29:38 GMT</pubDate><dc:creator>Andrew Pruski</dc:creator></item><item><title>RE: getting total disk space</title><link>http://www.sqlservercentral.com/Forums/Topic1409804-391-1.aspx</link><description>[quote][b]Perry Whittle (1/29/2013)[/b][hr][quote][b]anthony.green (1/29/2013)[/b][hr]Many thanks for that, as I have not worked with mount points before (well not to my better knowledge) I was un aware of that, added to the knowledge bank.[/quote]Check my article at [url=http://www.sqlservercentral.com/articles/mount+points/75855/][u][b]this link[/b][/u][/url] for more info on mount points and SQL Server.The problem with mount points is that when you execute XP_FIXEDDRIVES it only enumerates the root drives and won't return information from the volume level. It's all detailed in my article, post back if you're unsure of the workings of it all.[/quote]Thanks Perry, added to my list of further reading.</description><pubDate>Tue, 29 Jan 2013 04:07:09 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>RE: getting total disk space</title><link>http://www.sqlservercentral.com/Forums/Topic1409804-391-1.aspx</link><description>[quote][b]anthony.green (1/29/2013)[/b][hr]Many thanks for that, as I have not worked with mount points before (well not to my better knowledge) I was un aware of that, added to the knowledge bank.[/quote]Check my article at [url=http://www.sqlservercentral.com/articles/mount+points/75855/][u][b]this link[/b][/u][/url] for more info on mount points and SQL Server.The problem with mount points is that when you execute XP_FIXEDDRIVES it only enumerates the root drives and won't return information from the volume level. It's all detailed in my article, post back if you're unsure of the workings of it all.</description><pubDate>Tue, 29 Jan 2013 04:03:48 GMT</pubDate><dc:creator>Perry Whittle</dc:creator></item><item><title>RE: getting total disk space</title><link>http://www.sqlservercentral.com/Forums/Topic1409804-391-1.aspx</link><description>[quote][b]opc.three (1/26/2013)[/b][hr][quote][b]anthony.green (1/22/2013)[/b][hr]Powershell will probably be the best bet on that[code="other"]Get-WmiObject win32_logicaldisk  | where-Object {$_.providername -like ''} | select deviceid, size[/code][/quote] Win32_LogicalDisk will work in most cases but know that it does not pickup mount points. For a more comprehensive view (post Windows 2000 Server) use the Win32_Volume class instead.[code="plain"]Get-WmiObject Win32_Volume | gm[/code][/quote]Many thanks for that, as I have not worked with mount points before (well not to my better knowledge) I was un aware of that, added to the knowledge bank.</description><pubDate>Tue, 29 Jan 2013 02:51:23 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>RE: getting total disk space</title><link>http://www.sqlservercentral.com/Forums/Topic1409804-391-1.aspx</link><description>OPC is correct, XP_FIXEDDRIVES cannot enumerate mounted volumes. A straight WMI call will also work using [code]wmic volume get capacity, "free space", name[/code]You can also supply an output file and remote node names too[code="other"]wmic /output:"c:\temp\mountsizes.txt" /node:sqlnode1,sqlnode2,sqlnode3,sqlnode4volume get capacity, "free space", name[/code]</description><pubDate>Tue, 29 Jan 2013 02:24:48 GMT</pubDate><dc:creator>Perry Whittle</dc:creator></item><item><title>RE: getting total disk space</title><link>http://www.sqlservercentral.com/Forums/Topic1409804-391-1.aspx</link><description>[quote][b]mani@123 (1/22/2013)[/b][hr]SERVER2008:declare @svrName varchar(255)declare @sql varchar(400)--by default it will take the current server name, we can the set the server name as wellset @svrName = @@SERVERNAME[font="Arial Black"]set @sql = 'powershell.exe [/font]-c "Get-WmiObject -Class Win32_Volume -Filter ''DriveType = 3'' | select name,capacity,freespace | foreach{$_.name+''|''+$_.capacity/1048576+''%''+$_.freespace/1048576+''*''}"'--creating a temporary tableCREATE TABLE #output(line varchar(255))--inserting disk name, total space and free space value in to temporary tableinsert #output[font="Arial Black"]EXEC xp_cmdshell @sql[/font][/quote]+10000000000000000000000 Mani!!!  I absolutely freakin' love it! :-)  I was starting to think I was the only one in the world that did that!</description><pubDate>Sat, 26 Jan 2013 20:12:51 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: getting total disk space</title><link>http://www.sqlservercentral.com/Forums/Topic1409804-391-1.aspx</link><description>[quote][b]Gazareth (1/26/2013)[/b][hr]Can't agree more opc. Powershell's a bit of a cow to learn but it's so useful I'd recommend it to all DBA's. Great tool to have in your utility belt![/quote]:-P It sounds like you have done some work with it but I am not sure I agree with [i]cow[/i] simile. Admittedly it's hard for me to convey a fresh perspective because I started playing with PowerShell ~3 years ago and have never looked back. If I never write another Windows batch or VBScript file again it will be too soon. That said, I only got serious about learning it and applying it in a structured way within the last year or so. I am reading this book now:[u][url=http://www.amazon.com/Learn-Windows-PowerShell-Month-Lunches/dp/1617291080]Learn Windows PowerShell 3 in a Month of Lunches by Don Jones and Jeffrey Hicks (aka Professor PowerShell[/url][/u]I am about 1/3 of the way through and it has already filled in many knowledge gaps left around by learning on my own and through repurposing bits of scripts I found on the net. The book focuses on using PowerShell to accomplish real tasks right away rather than treating it as a scripting language you have to learn about from end-to-end before you can do anything useful. The other great thing it does is teach you how to fish, and what I mean by that is it teaches you how to use the help system built into PowerShell which is pretty robust and user-friendly such that once you learn it you can move around and pickup new things quite easily.The book does have a "system administrator" spin as that is its core audience but we can't kid ourselves, most DBAs have to wear that hat all too often so learning PowerShell through that lense is not a stretch at all. I am easily able to apply everything I have learned so far when using the SQL Server PowerShell provider.</description><pubDate>Sat, 26 Jan 2013 16:44:50 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: getting total disk space</title><link>http://www.sqlservercentral.com/Forums/Topic1409804-391-1.aspx</link><description>Can't agree more opc. Powershell's a bit of a cow to learn but it's so useful I'd recommend it to all DBA's. Great tool to have in your utility belt!</description><pubDate>Sat, 26 Jan 2013 16:14:44 GMT</pubDate><dc:creator>Gazareth</dc:creator></item><item><title>RE: getting total disk space</title><link>http://www.sqlservercentral.com/Forums/Topic1409804-391-1.aspx</link><description>[quote][b]Bhuvnesh (1/26/2013)[/b][hr]why cant we use "xp_fixeddrive" ?[/quote]I suppose you could. I haven't used it since the SQL 2000 days and if what I am reading online is correct however it still does not report on mount points.[u][url=http://connect.microsoft.com/SQLServer/feedback/details/301832/listing-mount-point-information-from-within-sql-server]http://connect.microsoft.com/SQLServer/feedback/details/301832/listing-mount-point-information-from-within-sql-server[/url][/u]Personally I prefer to do this kind of work outside SQL Server, and have for quite a long time. With a single PowerShell script running on one my 'food court' database server I check available space on all the servers across my environment and store the results in a database. I could do alerting from there as well but I haven't had to. I try to leave that to monitoring tools like SCOM or SQLdm.</description><pubDate>Sat, 26 Jan 2013 11:50:12 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: getting total disk space</title><link>http://www.sqlservercentral.com/Forums/Topic1409804-391-1.aspx</link><description>why cant we use "xp_fixeddrive" ?</description><pubDate>Sat, 26 Jan 2013 09:09:11 GMT</pubDate><dc:creator>Bhuvnesh</dc:creator></item><item><title>RE: getting total disk space</title><link>http://www.sqlservercentral.com/Forums/Topic1409804-391-1.aspx</link><description>[quote][b]anthony.green (1/22/2013)[/b][hr]Powershell will probably be the best bet on that[code="other"]Get-WmiObject win32_logicaldisk  | where-Object {$_.providername -like ''} | select deviceid, size[/code][/quote] Win32_LogicalDisk will work in most cases but know that it does not pickup mount points. For a more comprehensive view (post Windows 2000 Server) use the Win32_Volume class instead.[code="plain"]Get-WmiObject Win32_Volume | gm[/code]</description><pubDate>Sat, 26 Jan 2013 08:49:05 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: getting total disk space</title><link>http://www.sqlservercentral.com/Forums/Topic1409804-391-1.aspx</link><description>DECLARE @sqlver sql_variantDECLARE @sqlver2 varchar(20)DECLARE @sqlver3 intSELECT @sqlver = SERVERPROPERTY('productversion')SELECT @sqlver2 = CAST(@sqlver AS varchar(20)) select @sqlver3 = SUBSTRING(@sqlver2,1,1)-- 1 = 2008 8 = 2000 and 9 = 2005 1 is short for 10BEGIN --select @sqlver3 only uncomment to see state of versionIF @sqlver3 = 1 GOTO SERVER2008IF @sqlver3 = 9 GOTO SERVER2000IF @sqlver3 = 8 GOTO SERVER2000GOTO THEENDENDSERVER2008:declare @svrName varchar(255)declare @sql varchar(400)--by default it will take the current server name, we can the set the server name as wellset @svrName = @@SERVERNAMEset @sql = 'powershell.exe -c "Get-WmiObject -Class Win32_Volume -Filter ''DriveType = 3'' | select name,capacity,freespace | foreach{$_.name+''|''+$_.capacity/1048576+''%''+$_.freespace/1048576+''*''}"'--creating a temporary tableCREATE TABLE #output(line varchar(255))--inserting disk name, total space and free space value in to temporary tableinsert #outputEXEC xp_cmdshell @sql--script to retrieve the values in GB from PS Script outputselect rtrim(ltrim(SUBSTRING(line,1,CHARINDEX('|',line) -1))) as drive ,round(cast(rtrim(ltrim(SUBSTRING(line,CHARINDEX('%',line)+1, (CHARINDEX('*',line) -1)-CHARINDEX('%',line)) )) as Float) /1024 ,0)as 'freespace' ,round(cast(rtrim(ltrim(SUBSTRING(line,CHARINDEX('|',line)+1, (CHARINDEX('%',line) -1)-CHARINDEX('|',line)) )) as Float)/1024,0) as 'totalspace' ,((round(cast(rtrim(ltrim(SUBSTRING(line,CHARINDEX('%',line)+1, (CHARINDEX('*',line) -1)-CHARINDEX('%',line)) )) as Float) /1024 ,0)) / (round(cast(rtrim(ltrim(SUBSTRING(line,CHARINDEX('|',line)+1, (CHARINDEX('%',line) -1)-CHARINDEX('|',line)) )) as Float)/1024,0)) * 100) as percentfreefrom #outputwhere line like '[A-Z][:]%'--and ((round(cast(rtrim(ltrim(SUBSTRING(line,CHARINDEX('%',line)+1, -- (CHARINDEX('*',line) -1)-CHARINDEX('%',line)) )) as Float) /1024 ,0)) / (round(cast(rtrim(ltrim(SUBSTRING(line,CHARINDEX('|',line)+1, --(CHARINDEX('%',line) -1)-CHARINDEX('|',line)) )) as Float)/1024,0)) * 100) &amp;lt; 5order by drive--script to drop the temporary tabledrop table #outputGOTO THEENDSERVER2000:SET NOCOUNT ON;DECLARE @v_cmd nvarchar(255),@v_drive char(99),@v_sql nvarchar(255),@i intSELECT @v_cmd = 'fsutil volume diskfree %d%'SET @i = 1CREATE TABLE #drives(iddrive smallint ,drive char(99))CREATE TABLE #t(drive char(99),shellCmd nvarchar(500));CREATE TABLE #total(drive char(99),freespace decimal(9,2), totalspace decimal(9,2));-- Use mountvol command to INSERT #drives (drive) EXEC master..xp_cmdshell 'mountvol'DELETE #drives WHERE drive not like '%:\%' or drive is nullWHILE (@i &amp;lt;= (SELECT count(drive) FROM #drives))BEGIN UPDATE #drives  SET iddrive=@i WHERE drive = (SELECT TOP 1 drive FROM #drives WHERE iddrive IS NULL)  SELECT @v_sql = REPLACE(@v_cmd,'%d%',LTRIM(RTRIM(drive))) from #drives where iddrive=@i INSERT #t(shellCmd)  EXEC master..xp_cmdshell @v_sql  UPDATE #t  SET #t.drive = d.drive FROM #drives d WHERE #t.drive IS NULL and iddrive=@i SET @i = @i + 1ENDINSERT INTO #totalSELECT bb.drive,CAST(CAST(REPLACE(REPLACE(SUBSTRING(shellCmd,CHARINDEX(':',shellCmd)+1,LEN(shellCmd)),SPACE(1),SPACE(0)),char(13),SPACE(0)) AS NUMERIC(32,2))/1024/1024/1024 AS DECIMAL(9,2)) as freespace,tt.titi as totalFROM #t bbJOIN (SELECT drive,CAST(CAST(REPLACE(REPLACE(SUBSTRING(shellCmd,CHARINDEX(':',shellCmd)+1,LEN(shellCmd)),SPACE(1),SPACE(0)),char(13),SPACE(0)) AS NUMERIC(32,2))/1024/1024/1024 AS DECIMAL(9,2)) as titiFROM #tWHERE drive IS NOT NULLAND shellCmd NOT LIKE '%free bytes%') ttON bb.drive = tt.driveWHERE bb.drive IS NOT NULLAND bb.shellCmd NOT LIKE '%avail free bytes%'AND bb.shellCmd LIKE '%free bytes%';-- SET FreespaceTimestamp = (GETDATE())SELECT RTRIM(LTRIM(drive)) as drive ,freespace ,totalspace ,CAST((freespace/totalspace * 100) AS DECIMAL(5,2)) as [percent free]FROM #total--WHERE (freespace/totalspace * 100) &amp;lt; 5ORDER BY driveDROP TABLE #drivesDROP TABLE #tDROP TABLE #totalTHEEND:</description><pubDate>Tue, 22 Jan 2013 13:11:27 GMT</pubDate><dc:creator>Mani Dev</dc:creator></item><item><title>RE: getting total disk space</title><link>http://www.sqlservercentral.com/Forums/Topic1409804-391-1.aspx</link><description>Powershell will probably be the best bet on that[code="other"]Get-WmiObject win32_logicaldisk  | where-Object {$_.providername -like ''} | select deviceid, size[/code]</description><pubDate>Tue, 22 Jan 2013 01:19:42 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>getting total disk space</title><link>http://www.sqlservercentral.com/Forums/Topic1409804-391-1.aspx</link><description>i want to find the total drive space in server instaed of free space , can any one send the script ?</description><pubDate>Mon, 21 Jan 2013 23:39:32 GMT</pubDate><dc:creator>ramyours2003</dc:creator></item></channel></rss>