﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by Haidong Ji / Article Discussions / Article Discussions by Author  / Monitoring Disk Space and Sending Alerts with TSQL / 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>Mon, 20 May 2013 08:26:14 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>Ji Haidong,Would you have a Mount Point version of this script?Here is what I use now with out the email feature.Maybe it can be used as a good starting point.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 -ComputerName ' + QUOTENAME(@svrName,'''') + ' -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 MB from PS Script outputselect rtrim(ltrim(SUBSTRING(line,1,CHARINDEX('|',line) -1))) as drivename      ,round(cast(rtrim(ltrim(SUBSTRING(line,CHARINDEX('|',line)+1,      (CHARINDEX('%',line) -1)-CHARINDEX('|',line)) )) as Float),0) as 'capacity(MB)'      ,round(cast(rtrim(ltrim(SUBSTRING(line,CHARINDEX('%',line)+1,      (CHARINDEX('*',line) -1)-CHARINDEX('%',line)) )) as Float),0) as 'freespace(MB)'from #outputwhere line like '[A-Z][:]%'order by drivename--script to retrieve the values in GB from PS Script outputselect rtrim(ltrim(SUBSTRING(line,1,CHARINDEX('|',line) -1))) as drivename      ,round(cast(rtrim(ltrim(SUBSTRING(line,CHARINDEX('|',line)+1,      (CHARINDEX('%',line) -1)-CHARINDEX('|',line)) )) as Float)/1024,0) as 'capacity(GB)'      ,round(cast(rtrim(ltrim(SUBSTRING(line,CHARINDEX('%',line)+1,      (CHARINDEX('*',line) -1)-CHARINDEX('%',line)) )) as Float) /1024 ,0)as 'freespace(GB)'from #outputwhere line like '[A-Z][:]%'order by drivename--script to drop the temporary tabledrop table #output</description><pubDate>Fri, 05 Apr 2013 16:27:04 GMT</pubDate><dc:creator>juan Munoz</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>Here is the code I use to get mount point information.  I'm sure someone has a better way but I couldn't find it/*  This code will go out to the O/S and check for free space at the drive level  It will only check volumes that have database files (mdf,ldf,ndf) (sysaltfiles)  It will only check volumes attached to the node*/Declare @svrName     varchar(255)      , @sql         varchar(400)      , @Path        varchar(400)      , @Label       varchar(400)      , @Capacity    Decimal(12,2)      , @FreeSpace   Decimal(12,2)      , @PercentFree Decimal(12,2)      , @Row         int      , @MessageBody NVARCHAR(MAX)      , @Subject     NVARCHAR(250)--Declare @output TABLE      ( row  int IDENTITY(1,1) NOT NULL      , line varchar(255) ) --SET NOCOUNT ON--BEGIN -- use powershell to go ou to the O/S and get a list of all volumes attached to the server    set @sql = 'powershell.exe -c "gwmi win32_volume'             + '|'             + 'where-object {$_.filesystem -match ''ntfs''}'             + '|'             + 'format-list name,capacity,freespace,label"' --     insert @output        EXEC xp_cmdshell @sql --     Delete @output where line is null     END--WHILE EXISTS ( SELECT *                 FROM @OutPut                where line like 'name      : %'                   or line like 'capacity  : %'                   or line like 'label     : %'                   OR line like 'freespace : %' )      BEGIN            SELECT TOP 1                   @Row  = row                 , @Path = substring(Line,13,len(Line))              FROM @Output             WHERE Line like 'name      : %'            DELETE @Output             WHERE row = @Row--            SELECT TOP 1                   @Row  = row                 , @Label = substring(Line,13,len(Line))              FROM @Output             WHERE Line like 'label     : %'            DELETE @Output             WHERE row = @Row--            SELECT TOP 1                   @Row      = row                 , @Capacity = cast(substring(Line,13,len(line)) as bigint)/1048576.00              FROM @Output             WHERE Line like 'capacity  : %'            DELETE @Output             WHERE row = @Row--            SELECT TOP 1                   @Row       = row                 , @FreeSpace = cast(substring(line,13,len(line)) as bigint)/1048576.00              FROM @Output             WHERE Line like 'freespace : %'            DELETE @Output             WHERE row = @Row--            SET @PercentFree = cast( ( ( ( @Capacity - ( @Capacity - @FreeSpace ) ) / @Capacity ) * 100.00 ) as decimal(12,2) )--            IF ( @PercentFree &amp;lt; 6             and @Path not like '\\?\Volume%'             and @Path in ( select reverse(substring(reverse(filename),charindex('\',reverse(filename)),100)) from master.dbo.sysaltfiles) )               BEGIN -- Ready email body                     Select @MessageBody = 'Disk Space Alert'                          + char(10) + char(13)                          + '        Computer Name   = ' + cast(SERVERPROPERTY('ComputerNamePhysicalNetBIOS') as nvarchar(25))                          + char(10) + char(13)                          + '        Instance Name   = ' + cast(@@servername as nvarchar(50))                          + char(10) + char(13)                          + '        Drive or Path   = ' + @Path                          + char(10) + char(13)                          + '        Label           = ' + @Label                          + char(10) + char(13)                          + '        Capacity (MB)   = ' + cast(@Capacity as nvarchar(20))                          + char(10) + char(13)                          + '        Free Space (MB) = ' + cast(@FreeSpace as nvarchar(20))                          + char(10) + char(13)                          + '        %Free Space     = ' + cast(@PercentFree as nvarchar(20))                          + char(10) + char(13)	                      + '        EventTime       = ' + convert(varchar, getdate())                          + char(10) + char(13)--                    BEGIN -- Send Email                          SET @SUBJECT = 'SQL Monitor Disk Space Alert: '+ @Path + ' is at ' + cast(@PercentFree as nvarchar(20)) + '% free'                          EXEC msdb.dbo.sp_send_dbmail @profile_name = 'SQLDBA Profile'                                                     , @recipients   = 'My.Email@MyCompany.com'                                                     , @SUBJECT      = @Subject                                                     , @Body         = @MessageBody                                                     , @importance   = 'High'                                                     , @exclude_query_output = 1                    END--               ENDEND</description><pubDate>Tue, 28 Feb 2012 13:59:46 GMT</pubDate><dc:creator>Michael-401546</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>Hi Bob very good answer.Could you please post the code of your working solution?Thanks</description><pubDate>Sun, 29 Jan 2012 07:33:51 GMT</pubDate><dc:creator>M P-486151</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>Bob, would you mind sharing how you check mount point free space with CHKDSK in Tsql ?</description><pubDate>Tue, 22 Nov 2011 20:23:21 GMT</pubDate><dc:creator>SQLEngine</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>Hello Haidong Ji,How can i change the script into percentage free.In you script you mentioned a hard limit of 2GB,but i want it in percentage.Say if the drive is 10 % free then send the alert.Can you please post that.Thanks In Advance</description><pubDate>Wed, 08 Dec 2010 11:01:22 GMT</pubDate><dc:creator>kishore.kodukulla-non-empl</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>I am trying to set up a SSIS Package where this sql query will run through all of my servers. (this part is done)I set that up to do a performance test on all the servers,however now I am trying to check disk space on all 128 servers as well. This query is not working for me though. I believe it is due to the temp. tables possibly? Can someone help me? Thanks,</description><pubDate>Fri, 16 Oct 2009 13:42:49 GMT</pubDate><dc:creator>Bryan_299</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>Here's a simple script for getting volume capacity and free space info when you have mount points.   It uses a combination of WMI, ADO, and VBSCript.  You can trigger the script via a SQLAgent job or the Windows Task Scheduler.  I have it running as a daily SQLAgent job.  It populates a table that has date, host name, volume name, capacity, and free space columns. You'll need to modify this script to suit your particular environment and needs.  I apologize that this is not a nice, clean SQL script, but I'm a sysadmin-turned-DBA and these are the tools I had available.Option Explicit'' *********** Modify the following constants to suit your environment ******************Const strRegPath = "HKLM\Software\scharfco\servers" 'REG_MULTI_SZ value containing names of servers to checkConst strConn =  "Provider=SQLOLEDB;Data Source=MyServer;Trusted_Connection=Yes;Initial Catalog=MyDatabase"' ***************************************************************************************Const adOpenStatic = 3Const adLockOptimistic = 3Dim iDim strComputer, objWMIService, colItems, objItemDim WshShellDim objConnection, objCmddim strServer, strVolume, intCapacity, intFreeSpaceSet WshShell = Wscript.CreateObject("WScript.Shell")'Get server list from the Windows registry'you could also pull your server list from a tableDim strServerListstrServerList = WshShell.RegRead(strRegPath)Set objConnection = CreateObject("ADODB.Connection")set objCmd = CreateObject("ADODB.Command")objConnection.Open strConnobjCmd.activeConnection = objConnectionFor i = 0 To Ubound(strServerList)  If isAlive(strServerList(i)) Then    Set objWMIService = GetObject("winmgmts:\\" &amp; strServerList(i) &amp; "\root\cimv2")    Set colItems = objWMIService.ExecQuery("Select * from Win32_Volume where DriveType = '3'")    For Each objItem In colItems        'WScript.Echo strServerList(i) &amp; "," &amp; "," &amp; objItem.Name &amp; "," &amp; int(objItem.Capacity / 1048576) &amp; "," &amp; int(objItem.FreeSpace / 1048576)        strServer = strServerList(i)        strVolume = objItem.Name        intCapacity =  int(objItem.Capacity / 1048576)        intFreeSpace = int(objItem.FreeSpace / 1048576)        wscript.echo strServer, strVolume, intCapacity, intFreeSpace        objCmd.commandtext = "exec WriteVolumeStats @Server = '" &amp; strServer &amp; "', @VolumeID = '" &amp; strVolume &amp; "', @Capacity = " &amp; intCapacity &amp; ", @FreeSpace = " &amp; intFreeSpace        'objCmd.execute    Next  End ifNextFunction IsAlive(strTarget)'Pings the target machine. Returns 1 if the machine responds; 0 otherwise  dim WshExec, strPingResults  Set WshShell = WScript.CreateObject("WScript.Shell")  Set WshExec = WshShell.Exec("ping -n 1 -w 2000 " &amp; strTarget)  strPingResults = LCase(WshExec.StdOut.ReadAll)  If InStr(strPingResults, "reply from") Then    IsAlive = True  Else    IsAlive = False  End IfEnd Function</description><pubDate>Thu, 25 Jun 2009 12:22:44 GMT</pubDate><dc:creator>Bennett Scharf</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>hi bobi have exactly the problem you described here.we are using mountpoints with an amount of 100 tb and more...so now i want to find out the size and free space of all mountpoints in all servers we have got.i've tried wmi but as you've written... it is not working properly.maybe you can help me/us in that case?thanks in advancedaniel (vienna)</description><pubDate>Thu, 17 Apr 2008 04:54:10 GMT</pubDate><dc:creator>daniel-471430</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>I've read the helpful comments here. i am using it in a similar way.but how can i read the sizes of mount points?thanks for your help!cheersdaniel</description><pubDate>Thu, 17 Apr 2008 04:48:35 GMT</pubDate><dc:creator>daniel-471430</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>hi how can i edit this sp so i get also the percentage? and modify the alert if i have less than 10%? :crying:</description><pubDate>Mon, 14 Apr 2008 09:35:43 GMT</pubDate><dc:creator>DBA-640728</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>hello, thank you for your script, question how can i run with my other servers?</description><pubDate>Tue, 01 Apr 2008 14:25:28 GMT</pubDate><dc:creator>DBA-640728</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>For anyone else who needs to modify the script to use SQL 2005 dbmail just change (assuming db mail is correctly set up already)....EXEC master..xp_sendmail @recipients = 'email@domain.com',@subject = @MailSubject,@message = @AlertMessagetoEXEC msdb..sp_send_dbmail @recipients = 'email@domain.com',@subject = @MailSubject,@body = @AlertMessage</description><pubDate>Mon, 05 Nov 2007 06:01:30 GMT</pubDate><dc:creator>dt293</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>I am new to SQL2005. I received the following error when execute the SPI check on the Help inside the SQL2005 and it warn us not to use the SQL_Mail but use the Database Mail instead and I have successfully configurated the SMTP database Mail. However, how can I change the SP to use the Database Mail instead of the SQL sendMailThanks</description><pubDate>Mon, 01 Oct 2007 19:57:27 GMT</pubDate><dc:creator>gbgykkcci00000-r</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>I am new to SQL2005. I received the following error when execute the SPI check on the Help inside the SQL2005 and it warn us not to use the SQL_Mail but use the Database Mail instead and I have successfully configurated the SMTP database Mail. However, how can I change the SP to use the Database Mail instead of the SQL sendMailThanks</description><pubDate>Mon, 01 Oct 2007 19:56:11 GMT</pubDate><dc:creator>gbgykkcci00000-r</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>I am new to SQL2005. I received the following error when execute the SPI check on the Help inside the SQL2005 and it warn us not to use the SQL_Mail but use the Database Mail instead and I have successfully configurated the SMTP database Mail. However, how can I change the SP to use the Database Mail instead of the SQL sendMailThanks</description><pubDate>Mon, 01 Oct 2007 19:55:30 GMT</pubDate><dc:creator>gbgykkcci00000-r</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>I am new to SQL2005. I received the following error when execute the SPI check on the Help inside the SQL2005 and it warn us not to use the SQL_Mail but use the Database Mail instead and I have successfully configurated the SMTP database Mail. However, how can I change the SP to use the Database Mail instead of the SQL sendMailThanks</description><pubDate>Mon, 01 Oct 2007 19:54:59 GMT</pubDate><dc:creator>gbgykkcci00000-r</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>I am new to SQL2005. I received the following error when execute the SP-- Msg 15281, Level 16, State 1, Procedure !!!!x!!!!p_sendmail, Line 1-- SQL Server blocked access to procedure '!!!!y!!!!s.xp_sendmail' of component 'SQL Mail XPs' because this --- component is turned off as part of the security configuration for this server. A system administrator -I check on the Help inside the SQL2005 and it warn us not to use the SQL_Mail but use the Database Mail instead and I have successfully configurated the SMTP database Mail. However, how can I change the SP to use the Database Mail instead of the SQL sendMailThanks</description><pubDate>Mon, 01 Oct 2007 19:54:50 GMT</pubDate><dc:creator>gbgykkcci00000-r</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>I am new to SQL2005. I received the following error when execute the SP-- Msg 15281, Level 16, State 1, Procedure xp_sendmail, Line 1-- SQL Server blocked access to procedure 'ys.xp_sendmail' of component 'SQL Mail XPs' because this --- component is turned off as part of the security configuration for this server. A system administrator -I check on the Help inside the SQL2005 and it warn us not to use the SQL_Mail but use the Database Mail instead and I have successfully configurated the SMTP database Mail. However, how can I change the SP to use the Database Mail instead of the SQL sendMailThanks</description><pubDate>Mon, 01 Oct 2007 19:54:26 GMT</pubDate><dc:creator>gbgykkcci00000-r</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>I am new to SQL2005. I received the following error when execute the SP[quote][quote](3 row(s) affected)-- Msg 15281, Level 16, State 1, Procedure xp_sendmail, Line 1-- SQL Server blocked access to procedure 'sys.xp_sendmail' of component 'SQL Mail XPs' because this --- component is turned off as part of the security configuration for this server. A system administrator --- can enable the use of 'SQL Mail XPs' by using sp_configure. For more information about --- ---- enabling 'SQL -- Mail XPs', see "Surface Area Configuration" in SQL Server Books Online. -- Msg 15281, Level 16, State 1, Procedure xp_sendmail, Line 1-- SQL Server blocked access to procedure 'sys.xp_sendmail' of component 'SQL Mail XPs' because this --- component is turned off as part of the security configuration for this server. A system administrator --- can enable the use of 'SQL Mail XPs' by using sp_configure. For more information about -- -- ng 'SQL -- l XPs', see "Surface Area Configuration" in SQL Server Books Online[/quote]. [/quote]I check on the Help inside the SQL2005 and it warn us not to use the SQL_Mail but use the Database Mail instead and I have successfully configurated the SMTP database Mail. However, how can I change the SP to use the Database Mail instead of the SQL sendMailThanks</description><pubDate>Mon, 01 Oct 2007 19:53:46 GMT</pubDate><dc:creator>gbgykkcci00000-r</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>I am new to SQL2005. I received the following error when execute the SP[quote](3 row(s) affected)-- Msg 15281, Level 16, State 1, Procedure xp_sendmail, Line 1-- SQL Server blocked access to procedure 'sys.xp_sendmail' of component 'SQL Mail XPs' because this --- component is turned off as part of the security configuration for this server. A system administrator --- can enable the use of 'SQL Mail XPs' by using sp_configure. For more information about --- ---- enabling 'SQL -- Mail XPs', see "Surface Area Configuration" in SQL Server Books Online. -- Msg 15281, Level 16, State 1, Procedure xp_sendmail, Line 1-- SQL Server blocked access to procedure 'sys.xp_sendmail' of component 'SQL Mail XPs' because this --- component is turned off as part of the security configuration for this server. A system administrator --- can enable the use of 'SQL Mail XPs' by using sp_configure. For more information about -- -- ng 'SQL -- l XPs', see "Surface Area Configuration" in SQL Server Books Online[/quote]. I check on the Help inside the SQL2005 and it warn us not to use the SQL_Mail but use the Database Mail instead and I have successfully configurated the SMTP database Mail. However, how can I change the SP to use the Database Mail instead of the SQL sendMailThanks</description><pubDate>Mon, 01 Oct 2007 19:53:22 GMT</pubDate><dc:creator>gbgykkcci00000-r</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>I am new to SQL2005. I received the following error when execute the SP(3 row(s) affected)-- Msg 15281, Level 16, State 1, Procedure xp_sendmail, Line 1-- SQL Server blocked access to procedure 'sys.xp_sendmail' of component 'SQL Mail XPs' because this --- component is turned off as part of the security configuration for this server. A system administrator --- can enable the use of 'SQL Mail XPs' by using sp_configure. For more information about --- ---- enabling 'SQL -- Mail XPs', see "Surface Area Configuration" in SQL Server Books Online. -- Msg 15281, Level 16, State 1, Procedure xp_sendmail, Line 1-- SQL Server blocked access to procedure 'sys.xp_sendmail' of component 'SQL Mail XPs' because this --- component is turned off as part of the security configuration for this server. A system administrator --- can enable the use of 'SQL Mail XPs' by using sp_configure. For more information about -- -- ng 'SQL -- l XPs', see "Surface Area Configuration" in SQL Server Books Online. I check on the Help inside the SQL2005 and it warn us not to use the SQL_Mail but use the Database Mail instead and I have successfully configurated the SMTP database Mail. However, how can I change the SP to use the Database Mail instead of the SQL sendMailThanks</description><pubDate>Mon, 01 Oct 2007 19:53:00 GMT</pubDate><dc:creator>gbgykkcci00000-r</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>I am new to SQL2005. I received the following error when execute the SP(3 row(s) affected)Msg 15281, Level 16, State 1, Procedure xp_sendmail, Line 1SQL Server blocked access to procedure 'sys.xp_sendmail' of component 'SQL Mail XPs' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'SQL Mail XPs' by using sp_configure. For more information about enabling 'SQL Mail XPs', see "Surface Area Configuration" in SQL Server Books Online. Msg 15281, Level 16, State 1, Procedure xp_sendmail, Line 1SQL Server blocked access to procedure 'sys.xp_sendmail' of component 'SQL Mail XPs' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'SQL Mail XPs' by using sp_configure. For more information about enabling 'SQL Mail XPs', see "Surface Area Configuration" in SQL Server Books Online. I check on the Help inside the SQL2005 and it warn us not to use the SQL_Mail but use the Database Mail instead and I have successfully configurated the SMTP database Mail. However, how can I change the SP to use the Database Mail instead of the SQL sendMailThanks</description><pubDate>Mon, 01 Oct 2007 19:51:57 GMT</pubDate><dc:creator>gbgykkcci00000-r</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>Bob, We have a similar requirement to monitor mount points I would like to look at how you have used chkdisk and parsed the results. My email id is jullietl@yahoo.com.thanks</description><pubDate>Tue, 25 Sep 2007 09:11:40 GMT</pubDate><dc:creator>jullietl</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>&lt;P&gt;&lt;FONT face=Tahoma color=#111111&gt;This is a very useful script.  I have been looking for something like this.  However, can you tell me how to use database mail rather than xp_sendmail since "this feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.. To send mail from SQL Server, use Database Mail." (SQL Server 2005 Books Online)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#800000&gt;&lt;FONT face=Tahoma color=#111111&gt;Thanks!&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Wed, 19 Sep 2007 09:28:00 GMT</pubDate><dc:creator>Erin.</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>&lt;P&gt;Andy,&lt;/P&gt;&lt;P&gt;with WMI you have to be an admin on the server to use it.&lt;/P&gt;</description><pubDate>Fri, 14 Sep 2007 09:40:00 GMT</pubDate><dc:creator>Yelena Varshal</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>&lt;P&gt;Hi Bob,&lt;/P&gt;&lt;P&gt;If you are using Windows 2003 you can use WMI to get the mountpoint information that you need. Check out the Win32_Volume Class: &lt;/P&gt;&lt;P&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/aa394515.aspx"&gt;http://msdn2.microsoft.com/en-us/library/aa394515.aspx&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Also you can query any 2003 box remotely using this class.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Andy&lt;/P&gt;</description><pubDate>Fri, 14 Sep 2007 09:24:00 GMT</pubDate><dc:creator>j.a.c</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>&lt;P&gt;I saw the same problem. You can also click the "Print This!" button at the top of the article, and the print format has the word wrap on.&lt;/P&gt;&lt;P&gt;HTH,webrunner&lt;/P&gt;</description><pubDate>Fri, 14 Sep 2007 08:29:00 GMT</pubDate><dc:creator>webrunner</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>I have a number of servers that I need to monitor, both SQL Server 2000 and 2005.  I use similar code with an SSIS package to collect this information from all my servers to one database on one server.  SQL Server magazine had some articles (&lt;A href="http://www.sqlmag.com/Articles/ArticleID/95385/95385.html"&gt;http://www.sqlmag.com/Articles/ArticleID/95385/95385.html&lt;/A&gt; and &lt;A href="http://www.sqlmag.com/Articles/ArticleID/95745/95745.html"&gt;http://www.sqlmag.com/Articles/ArticleID/95745/95745.html&lt;/A&gt;) that had information on how to set this up.  Of course, you need a subscription to the magazine to read the articles.</description><pubDate>Fri, 14 Sep 2007 08:18:00 GMT</pubDate><dc:creator>Stephen Anderson-260031</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>&lt;P&gt;There have been many articles on this subject and all them rely on xp_fixeddrives to report total and free disk space.  This works well in smaller environments but in much larger environments, especially those including a SAN, this approach will fall short.  Most larger organizations, ones which hire Sr. Level DBAs are moving towards Mount Points on the Windows Servers.  The lack of drive letters, the need to spread multi-terabyte databases over dozens of filegroups, failover and DR environment integration, all facilitate the need for a different approach to space consideration and how to address the disk space.&lt;/P&gt;&lt;P&gt;WMI and many other tools in our SQL bag of tricks, fail to recoginize mountpoints in the environment.  If you xp_fixeddrives or even a WMIC query to look a drive which has a mount point with a terabyte of dataspace, all that is returned in the available space on the local disks.  This is really not going to help you and trust me, it looks "strange" on a report which you show 1.1 terabytes of data on a 17 Gb disk with 16 Gb Free. &lt;/P&gt;&lt;P&gt;There are ways to gather this information in C#, such as walking the directory tree, and adding the functionality through an extended stored procedure  but then you have to roll that out to all the servers and in secure/large environment, that is not always an easy or well received task.  &lt;/P&gt;&lt;P&gt;The other factor to consider is support for the developed solution.  Writing C# is great for many add-ons but not all DBAs are comfortable with creating, maintaining and/or deploying C# applications or SQL stored procedures/functions.   &lt;/P&gt;&lt;P&gt;The lack of this particular functionality (ability easily and accurately determine available/used disk space) and other similar functionaility is concerning and leaves many DBAs, who want to maintian a TSQL codebase, even if it uses COM XPs, at the mercy fo the monitoring software vendors out there.  Since CHKDSK can return the correct information on drives which have Mount Points, which is what I currently use to gather space information for TSQL by parsing the output, then I feel Microsoft should have updated the xp_fixeddrives routine to report the correct information or at least provided and documented a way of gathering that information.  Especiallys since SQL Server is by far the greatest benefactor of utilizing mount points to store the large amounts of data the want to boast the capability of being able to address.&lt;/P&gt;&lt;P&gt;This article and the use of the email system is well thought out and helpful but not as much in larger SQL farms which managing the data environment is even more critical.  I would also suggest adding a table in your database to store sent alerts (emails) and build in the functionality of storing the messages as part of the routine.  This will allow someone to do historical reporting and analysis of the alerts, this one and others, which have been sent out over a period of time without being dependent on reviewing the emails through a mail server and its client or through a mail interface.&lt;/P&gt;&lt;P&gt;Bob Wright&lt;/P&gt;&lt;P&gt;Sr. DBA/.NET Architect/SQL Architect&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;</description><pubDate>Fri, 14 Sep 2007 07:57:00 GMT</pubDate><dc:creator>Bob Wright-325851</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>Love the article, but the presentation is the pits!  I eventually copy/pasted the article in a text editor with word-wrap...</description><pubDate>Fri, 14 Sep 2007 07:47:00 GMT</pubDate><dc:creator>John Carter-291289</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>&lt;P&gt;In our environment, we have RAID drives that allow unlimited growth.  The only issue with that is that the DBA group doesn't set our databases to auto grow, so sometimes we hit the space limit set up for the particular database, even if we have plenty of disk space available.&lt;/P&gt;&lt;P&gt;Is there a way to write a stored proc to monitor &amp;amp; send an alert on the allocated disk space for a particular database??  That would be really useful for us.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description><pubDate>Fri, 14 Sep 2007 06:50:00 GMT</pubDate><dc:creator>bfraser</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>I actually used this one in conjunction with xp_SMTP_sendmail can't remember the xact SProc name, but it's an add-in sproc, and it was quick and didn't add much load to the server.</description><pubDate>Fri, 14 Sep 2007 06:48:00 GMT</pubDate><dc:creator>SuperDBA-207096</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>&lt;P&gt;It is good to know more than one way to do that.   My question is why this is better than using performance monitor and its alert to do the same thing.  Isn't it lesser work or resources by using performance monitor to track disk space and send alert?&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Fri, 14 Sep 2007 06:43:00 GMT</pubDate><dc:creator>OceanDeep</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>&lt;P&gt;&lt;SPAN id=Postmessage1_ucMessageControl_ReplyMsgRepeater__ctl1_lblFullMessage&gt;Thank you Haidong!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I know I've used this one, or some variation of it before in the past, it's very useful!&lt;/SPAN&gt;&lt;/P&gt;</description><pubDate>Fri, 14 Sep 2007 05:56:00 GMT</pubDate><dc:creator>SuperDBA-207096</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>Thank you Haidong Ji for your script.And what a very interesting twist to the tale that Guus Kramer added!, very cool and useful!</description><pubDate>Fri, 14 Sep 2007 01:18:00 GMT</pubDate><dc:creator>Marius Els</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>&lt;P&gt;Haidong Ji,&lt;/P&gt;&lt;P&gt;Try the next script (no e-mail part attached but it schoudn't be that difficult to add it);&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;CREATE&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;PROCEDURE&lt;/FONT&gt;&lt;FONT size=2&gt; [dbo]&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;FONT size=2&gt;[sp_diskspace] &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;AS&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;/*Displays the free space,free space percentage plus total drive size for a server*/&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;SET&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;NOCOUNT&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ON&lt;/P&gt;&lt;P&gt;DECLARE&lt;/FONT&gt;&lt;FONT size=2&gt; @hr &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;intDECLARE&lt;/FONT&gt;&lt;FONT size=2&gt; @fso &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;intDECLARE&lt;/FONT&gt;&lt;FONT size=2&gt; @drive &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;char&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;1&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;DECLARE&lt;/FONT&gt;&lt;FONT size=2&gt; @odrive &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;intDECLARE&lt;/FONT&gt;&lt;FONT size=2&gt; @TotalSize &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;varchar&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;20&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;DECLARE&lt;/FONT&gt;&lt;FONT size=2&gt; @MB &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;bigint&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;SET&lt;/FONT&gt;&lt;FONT size=2&gt; @MB &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt; 1048576&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;CREATE&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;TABLE&lt;/FONT&gt;&lt;FONT size=2&gt; #drives &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;drive &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;char&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;1&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;PRIMARY&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;KEY&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt;FreeSpace &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;NULL,&lt;/FONT&gt;&lt;FONT size=2&gt;TotalSize &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;NULL)&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;INSERT&lt;/FONT&gt;&lt;FONT size=2&gt; #drives&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;drive&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt;FreeSpace&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;EXEC&lt;/FONT&gt;&lt;FONT size=2&gt; master&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;FONT size=2&gt;dbo&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;FONT size=2&gt;xp_fixeddrives&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;EXEC&lt;/FONT&gt;&lt;FONT size=2&gt; @hr&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;sp_OACreate &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'Scripting.FileSystemObject'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt;@fso &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;OUT&lt;/P&gt;&lt;P&gt;IF&lt;/FONT&gt;&lt;FONT size=2&gt; @hr &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&amp;lt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt; 0 &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;EXEC&lt;/FONT&gt;&lt;FONT size=2&gt; sp_OAGetErrorInfo @fso&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;DECLARE&lt;/FONT&gt;&lt;FONT size=2&gt; dcur &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CURSOR&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;LOCAL&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;FAST_FORWARDFOR&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;SELECT&lt;/FONT&gt;&lt;FONT size=2&gt; drive &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;from&lt;/FONT&gt;&lt;FONT size=2&gt; #drives&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ORDER&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;by&lt;/FONT&gt;&lt;FONT size=2&gt; drive&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;OPEN&lt;/FONT&gt;&lt;FONT size=2&gt; dcur&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;FETCH&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;NEXT&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;FROM&lt;/FONT&gt;&lt;FONT size=2&gt; dcur &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;INTO&lt;/FONT&gt;&lt;FONT size=2&gt; @drive&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;WHILE&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;@@FETCH_STATUS&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;0&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;BEGIN&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;EXEC&lt;/FONT&gt;&lt;FONT size=2&gt; @hr &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt; sp_OAMethod @fso&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'GetDrive'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt; @odrive &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;OUT&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt; @drive&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;IF&lt;/FONT&gt;&lt;FONT size=2&gt; @hr &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&amp;lt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt; 0 &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;EXEC&lt;/FONT&gt;&lt;FONT size=2&gt; sp_OAGetErrorInfo @fso&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;EXEC&lt;/FONT&gt;&lt;FONT size=2&gt; @hr &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt; sp_OAGetProperty @odrive&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'TotalSize'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt; @TotalSize &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;OUT&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;IF&lt;/FONT&gt;&lt;FONT size=2&gt; @hr &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&amp;lt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt; 0 &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;EXEC&lt;/FONT&gt;&lt;FONT size=2&gt; sp_OAGetErrorInfo @odrive&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;UPDATE&lt;/FONT&gt;&lt;FONT size=2&gt; #drives&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;SET&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;A href="mailto:TotalSize=@TotalSize/@MB"&gt;TotalSize&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;@TotalSize&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;/&lt;/FONT&gt;&lt;FONT size=2&gt;@MB&lt;/A&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;WHERE&lt;/FONT&gt;&lt;FONT size=2&gt; drive&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;@drive&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;FETCH&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;NEXT&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;FROM&lt;/FONT&gt;&lt;FONT size=2&gt; dcur &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;INTO&lt;/FONT&gt;&lt;FONT size=2&gt; @drive&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ENDCLOSE&lt;/FONT&gt;&lt;FONT size=2&gt; dcur&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;DEALLOCATE&lt;/FONT&gt;&lt;FONT size=2&gt; dcur&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;EXEC&lt;/FONT&gt;&lt;FONT size=2&gt; @hr&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;sp_OADestroy @fso&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;IF&lt;/FONT&gt;&lt;FONT size=2&gt; @hr &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&amp;lt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt; 0 &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;EXEC&lt;/FONT&gt;&lt;FONT size=2&gt; sp_OAGetErrorInfo @fso&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;SELECT&lt;/FONT&gt;&lt;FONT size=2&gt; drive&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt;FreeSpace &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;as&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'Free(MB)'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt;TotalSize &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;as&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'Total(MB)'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;CAST&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;((&lt;/FONT&gt;&lt;FONT size=2&gt;FreeSpace&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;/(&lt;/FONT&gt;&lt;FONT size=2&gt;TotalSize&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;*&lt;/FONT&gt;&lt;FONT size=2&gt;1.0&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;))*&lt;/FONT&gt;&lt;FONT size=2&gt;100.0 &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;as&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;as&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'Free(%)'&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;FROM&lt;/FONT&gt;&lt;FONT size=2&gt; #drives&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ORDER&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;BY&lt;/FONT&gt;&lt;FONT size=2&gt; drive&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;DROP&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;TABLE&lt;/FONT&gt;&lt;FONT size=2&gt; #drives&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;8888888888888888888888888888888888888888888888888888888888888888888&lt;/P&gt;&lt;P&gt;Select the outcome from all your serers (using a databaselink) into a local "gathering-table"&lt;/P&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#1111ff&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;create&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;table&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; Disk_Capp &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;Servername &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;varchar&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;40&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;),&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; Volume &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;varchar&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;5&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;),&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;FreeMb &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; TotalMb &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; FreePCT &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;integer&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; date &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;datetime&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; runnum &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;integer&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;--The @runnum is a counter for each time you execute this script to keep track on history in the DISK_CAPP table&lt;/P&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;SET&lt;/FONT&gt;&lt;FONT size=2&gt; @Query &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'INSERT Disk_Capp SELECT '''&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;@servername&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;''',*,cast(getdate() as varchar(20)),'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;cast&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;@runnum &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;as&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;varchar&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;10&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;))+&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;' FROM OPENQUERY( [DBA_'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;@servername&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'],''SET FMTONLY OFF;EXEC master.dbo.sp_diskspace'')'&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;exec&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt; @Query &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/P&gt;&lt;/FONT&gt;&lt;P&gt;8888888888888888888888888888888888888888888888888888888888888888888&lt;/P&gt;&lt;P&gt;Mention that the you are authorized to use the SP_OAxxxxx procedures (open and close using the DBlinks 1 and 0 )&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;SET&lt;/FONT&gt;&lt;FONT size=2&gt; @Query_c1 &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'declare @var1 varchar(3000) set @var1 = ''EXEC [DBA_'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;@servername&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'].master.dbo.sp_configure ''show advanced options'',1 go reconfigure go'' exec (@var1)'&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;exec&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;@Query_c1&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;SET&lt;/FONT&gt;&lt;FONT size=2&gt; @Query_c2 &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'declare @var2 varchar(3000) set @var2 = ''EXEC [DBA_'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;@servername&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'].master.dbo.sp_configure ''Ole Automation Procedure'',1 go reconfigure go''exec (@var2)'&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;exec&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;@Query_c2&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt; 8888888888888888888888888888888888888888888888888888888888888888888&lt;/P&gt;&lt;P&gt;Hope you (or someone else) can use it. . .&lt;/P&gt;&lt;P&gt;GKramerThe Netherlands&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Thu, 13 Sep 2007 23:49:00 GMT</pubDate><dc:creator>Guus Kramer</dc:creator></item><item><title>RE: Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>&lt;P&gt;Previously it was giving error because i didn't have SQL Mail in Support Services.&lt;/P&gt;&lt;P&gt;Now it works fine for me. This is perfect.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Thu, 08 Jan 2004 10:54:00 GMT</pubDate><dc:creator>nap_parikh</dc:creator></item><item><title>Monitoring Disk Space and Sending Alerts with TSQL</title><link>http://www.sqlservercentral.com/Forums/Topic15135-102-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF=http://www.sqlservercentral.com/columnists/hji/monitoringdiskspaceandsendingalertswithtsql.asp&gt;http://www.sqlservercentral.com/columnists/hji/monitoringdiskspaceandsendingalertswithtsql.asp&lt;/A&gt;</description><pubDate>Sun, 10 Aug 2003 00:00:00 GMT</pubDate><dc:creator>Haidong Ji</dc:creator></item></channel></rss>