﻿<?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 Roy Carlson / Article Discussions / Article Discussions by Author  / Monitoring File Sizes in SQL Server Part 2 / 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>Wed, 22 May 2013 22:57:07 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Monitoring File Sizes in SQL Server Part 2</title><link>http://www.sqlservercentral.com/Forums/Topic318528-219-1.aspx</link><description>&lt;P&gt;Hi:&lt;/P&gt;&lt;DIV id=result_box dir=ltr&gt;this example them can be of utility&lt;/DIV&gt;&lt;P&gt;Function BDSql(strComputer)&lt;/P&gt;&lt;P&gt;Dim strSql 'Used to hold the SQL QueryDim objConn 'Used for the Connection objectDim objRst 'Used for the Recordset objectDim fecha&lt;/P&gt;&lt;P&gt;SQLDMOSecurity_Integrated  = 1 SQLDMOSecurity_Mixed         = 2 SQLDMOSecurity_Normal       = 0SQLDMOSecurity_Unknown   = 9 &lt;/P&gt;&lt;P&gt;strDBServerName = StrComputer&lt;/P&gt;&lt;P&gt;'On Error Resume Next&lt;/P&gt;&lt;P&gt;Set objConn = CreateObject("ADODB.Connection")objConn.Open "Provider=sqloledb;" &amp;amp; "Data Source=ccstnoc;" &amp;amp; "Initial Catalog=sistemanoc;" &amp;amp; "User Id=cuenta;" &amp;amp; "Password=password"&lt;/P&gt;&lt;P&gt;Set objSQLServer = CreateObject("SQLDMO.SQLServer")objSQLServer.LoginSecure = TrueobjSQLServer.Connect strDBServerName&lt;/P&gt;&lt;P&gt;If Err.Number &amp;lt;&amp;gt; 0 Then EXPLANATION = "Proceso termino con problemas" BDSql = False&lt;/P&gt;&lt;P&gt;End If&lt;/P&gt;&lt;P&gt;Set colDatabases = objSQLServer.Databases&lt;/P&gt;&lt;P&gt;'WScript.echo "SQL Version String: " &amp;amp; objSQLServer.VersionString&lt;/P&gt;&lt;P&gt;Select Case objSQLServer.ServerLoginMode(strDBServerName)   Case SQLDMOSecurity_Integrated      Login = "Login Mode: Allow Windows Authentication only."   Case SQLDMOSecurity_Mixed      Login = "Login Mode: Allow Windows Authentication or SQL Server Authentication."   Case SQLDMOSecurity_Normal      Login =  "Login Mode: Allow SQL Server Authentication only."   Case SQLDMOSecurity_Unknown      Login = "Login Mode: Security type unknown."End Select&lt;/P&gt;&lt;P&gt;'strSql3 = "delete from SqlServer where nombre = '" &amp;amp; strDBServerName &amp;amp; "'"'Set objRst3 = objConn.Execute(strSql3)&lt;/P&gt;&lt;P&gt;For Each objDatabase In colDatabases   'WScript.Echo objDatabase.Name   strDBName = objDatabase.Name   Set objDB = objSQLServer.Databases(strDBName)   'WScript.Echo "Total Size of Data File + Transaction Log of DB " &amp;amp; strDBName &amp;amp; ": " &amp;amp; objDB.Size &amp;amp; "(MB)"   'WScript.echo "Space Left (Data File + Transaction Log) for DB " &amp;amp; strDBName &amp;amp; ": " &amp;amp; objDB.SpaceAvailableInMB &amp;amp; "(MB)"     strSql3 = "insert into SqlServer(Nombre, VersionSQL, BaseDatos, TamanoBD, EspacioLibre, Login, fecha ) values('" &amp;amp; strDBServerName &amp;amp; "', '" &amp;amp; objSQLServer.VersionString &amp;amp; "', '" &amp;amp; strDBName &amp;amp; "', '" &amp;amp; objDB.Size &amp;amp; "', '" &amp;amp; objDB.SpaceAvailableInMB &amp;amp; "', '" &amp;amp; Login &amp;amp; "', '" &amp;amp; Date &amp;amp; "')"   Set objRst3 = objConn.Execute(strSql3)Next&lt;/P&gt;&lt;P&gt;BDSql = True&lt;/P&gt;&lt;P&gt;EXPLANATION = "proceso termino ok."End Function&lt;/P&gt;</description><pubDate>Wed, 08 Nov 2006 07:26:00 GMT</pubDate><dc:creator>german torrealba ramirez</dc:creator></item><item><title>RE: Monitoring File Sizes in SQL Server Part 2</title><link>http://www.sqlservercentral.com/Forums/Topic318528-219-1.aspx</link><description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am fairly new to VBs scripts and thought is this just what I need to update Our old Batch file process that does the same thing. But when I try to switch drives and then run the code it fails with Acess denied for the other drive (H:\)  Any one with any ideas.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; Thanks&lt;/P&gt;</description><pubDate>Wed, 08 Nov 2006 04:45:00 GMT</pubDate><dc:creator>Alan Brownlow</dc:creator></item><item><title>RE: Monitoring File Sizes in SQL Server Part 2</title><link>http://www.sqlservercentral.com/Forums/Topic318528-219-1.aspx</link><description>&lt;P&gt;Hi to all.&lt;/P&gt;&lt;P&gt;I think the title "Monitoring File Sizes in SQL Server" is not completely correct.&lt;/P&gt;&lt;P&gt;When noticing this title I thought '"this is what I'm looking for" but it seems to measure the fixed filesize from a file location but not the actual filesize.&lt;/P&gt;&lt;P&gt;For one of our apllication I have to measure the actual filesize due to some unexpected growth and shrinking so I was looking for a way to retrieve these sizes from the database.(Files must be fixed according the application vendor)The table "database.sysfiles" is not exact enough; This sys-table only contains the fixed filesize for each file but not the actual filling of this fixed size.&lt;/P&gt;&lt;P&gt;so I tried to write me a script to retrieve the actual filesize from the filesystem but unfortunately it retrieves the fixed size as well !!! ;-(&lt;/P&gt;&lt;P&gt;This script is far more easy to use for other purposses as the VBS / HTML script you suggesting in part 1 and part 2.&lt;/P&gt;&lt;P&gt;I hope you ( and others  ) can use it in any way whatsoever;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table #temp( col1 varchar(300))insert into #temp exec master..xp_cmdshell' dir\\&amp;lt;servername&amp;gt;\&amp;lt;foldername&amp;gt;'delete from #temp where ( col1 is null )delete from #temp where ( col1 not like '%&amp;lt;discrimination on some file names&amp;gt;%' )select  substring(col1,charindex('MMS',col1,1),50) as XX_filename,           substring(col1,charindex('MMS',col1,1)-18,18)  as XX_filesizefrom #temp&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;drop table #temp&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;From here you can hook up any other TSQL script.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;GKramerTHe Netherlands  &lt;/P&gt;</description><pubDate>Tue, 07 Nov 2006 23:59:00 GMT</pubDate><dc:creator>Guus Kramer</dc:creator></item><item><title>Monitoring File Sizes in SQL Server Part 2</title><link>http://www.sqlservercentral.com/Forums/Topic318528-219-1.aspx</link><description>Comments posted here are about the content posted at &lt;A HREF="temp"&gt;temp&lt;/A&gt;</description><pubDate>Thu, 26 Oct 2006 14:59:00 GMT</pubDate><dc:creator>rscarlson</dc:creator></item></channel></rss>