<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Dan's Blog : SQL Server 2005</title><link>http://blogs.msdn.com/dtjones/archive/tags/SQL+Server+2005/default.aspx</link><description>Tags: SQL Server 2005</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Using PowerShell to Get Data &amp; Log File Sizes</title><link>http://blogs.msdn.com/dtjones/archive/2009/03/21/using-powershell-to-get-data-log-file-sizes.aspx</link><pubDate>Sun, 22 Mar 2009 00:42:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9496563</guid><dc:creator>dtjones</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/dtjones/comments/9496563.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dtjones/commentrss.aspx?PostID=9496563</wfw:commentRss><wfw:comment>http://blogs.msdn.com/dtjones/rsscomments.aspx?PostID=9496563</wfw:comment><description>&lt;p&gt;I was playing around with PowerShell today (yes I’m was geeking out on Saturday afternoon) to learn how to access Performance Counters using PowerShell. My mission was to write a script that would return the Data File and Log File sizes for each database and a total for the instance. The good news is SQL Server already provides a bunch of fun performance counters and PowerShell has built-in support for accessing performance counters. I thought this was pretty cool so I decided to share it. In addition, I hadn’t blogged in a while and I was feeling bad about that. &lt;/p&gt;  &lt;p&gt;There are two groups of scripts and sample output below: 1) Data File Space and 2) Log File Space.&lt;/p&gt;  &lt;p&gt;Sorry about the formatting of the output I’m just being lazy today – after all it is Saturday.&lt;/p&gt;  &lt;p&gt;Have fun with it!&lt;/p&gt;  &lt;p&gt;Oh, btw: I was doing this on a Win7 machine (which I also need to give an update on) so I had to launch PS as administrator so it had access to the perf counters (same should be true on Vista and Windows Server 2K8). If you don’t launch as admin you’ll get an error that looks like this:&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000" size="2" face="Courier New"&gt;Get-Counter : The specified instance is not present.      &lt;br /&gt;At line:1 char:26       &lt;br /&gt;+ $DBDataFile = Get-Counter &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;#160; -Counter '\MSSQL$SQL2K8_01:Databases(*)\Data File(s) Size (KB)' -MaxSamples 1       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; + CategoryInfo&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : InvalidResult: (:) [Get-Counter], Exception       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; + FullyQualifiedErrorId : CounterApiError,Microsoft.PowerShell.Commands.GetCounterCommand&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Data File Space&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000" size="2" face="Courier New"&gt;#Displays the total Data File size for each database (including system databases)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000" size="2" face="Courier New"&gt;$DBDataFile = Get-Counter -Counter '\MSSQL$SQL2K8_01:Databases(*)\Data File(s) Size (KB)' -MaxSamples 1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000" size="2" face="Courier New"&gt;$DBDataFile.CounterSamples | where-object -FilterScript {($_.InstanceName -ne &amp;quot;_total&amp;quot;)} | sort-object -Property InstanceName | format-table @{Label = &amp;quot;Database&amp;quot;; Expression={$_.InstanceName}}, @{Label = &amp;quot;Total Data File(s) Size (MB)&amp;quot;; Express={$_.CookedValue/1000}} -AutoSize&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;Database Total Data File(s) Size (MB)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;-------- ----------------------------&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;ansicheck 2.304&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;master 4.096&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;model 1.28&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;msdb 10.752&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;mssqlsystemresource 61.696&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;pbm-prototype 2.048&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;tempdb 8.192&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;We can also just grab the total Data File space used by the instance:&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000" size="2" face="Courier New"&gt;$DBDataFile = Get-Counter -Counter '\MSSQL$SQL2K8_01:Databases(*)\Data File(s) Size (KB)' -MaxSamples 1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000" size="2" face="Courier New"&gt;$DBDataFile.CounterSamples | where-object -FilterScript {($_.InstanceName -eq &amp;quot;_total&amp;quot;)} | sort-object -Property InstanceName | format-table @{Label = &amp;quot;Database&amp;quot;; Expression={$_.InstanceName}}, @{Label = &amp;quot;Total Data File(s) Size (MB)&amp;quot;; Express={$_.CookedValue/1000}} -AutoSize&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;Database Total Data File(s) Size (MB)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;-------- ----------------------------&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;_total 90.368&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Log File Space&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000" size="2" face="Courier New"&gt;#Displays the total Log File size for each database (including system databases)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000" size="2" face="Courier New"&gt;$DBLogFile = Get-Counter -Counter '\MSSQL$SQL2K8_01:Databases(*)\Log File(s) Size (KB)' -MaxSamples 1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000" size="2" face="Courier New"&gt;$DBLogFile.CounterSamples | where-object -FilterScript {($_.InstanceName -ne &amp;quot;_total&amp;quot;)} | sort-object -Property InstanceName | format-table @{Label = &amp;quot;Database&amp;quot;; Expression={$_.InstanceName}}, @{Label = &amp;quot;Total Log File(s) Size (MB)&amp;quot;; Express={$_.CookedValue/1000}} -AutoSize&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;Database Total Log File(s) Size (MB)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;-------- ---------------------------&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;ansicheck 0.496&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;master&amp;#160;&amp;#160;&amp;#160; 1.016&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;model 0.504&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;msdb 0.504&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;mssqlsystemresource 0.504&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;pbm-prototype 1.016&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;tempdb 0.504&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;We can also just grab the total Log File space used by the instance:&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000" size="2" face="Courier New"&gt;$DBLogFile = Get-Counter -Counter '\MSSQL$SQL2K8_01:Databases(*)\Log File(s) Size (KB)' -MaxSamples 1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000" size="2" face="Courier New"&gt;$DBLogFile.CounterSamples | where-object -FilterScript {($_.InstanceName -eq &amp;quot;_total&amp;quot;)} | sort-object -Property InstanceName | format-table @{Label = &amp;quot;Database&amp;quot;; Expression={$_.InstanceName}}, @{Label = &amp;quot;Total Log File(s) Size (MB)&amp;quot;; Express={$_.CookedValue/1000}} –AutoSize&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;Database Total Log File(s) Size (MB)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;-------- ---------------------------&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000a0" size="2" face="Courier New"&gt;_total 4.544&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9496563" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dtjones/archive/tags/SQL+Server+2008/default.aspx">SQL Server 2008</category><category domain="http://blogs.msdn.com/dtjones/archive/tags/SQL+Server+2005/default.aspx">SQL Server 2005</category><category domain="http://blogs.msdn.com/dtjones/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/dtjones/archive/tags/PowerShell/default.aspx">PowerShell</category></item><item><title>SQL Server 2005 SP3 - Beta Now Available</title><link>http://blogs.msdn.com/dtjones/archive/2008/10/28/sql-server-2005-sp3-beta-now-available.aspx</link><pubDate>Tue, 28 Oct 2008 23:50:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9020938</guid><dc:creator>dtjones</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/dtjones/comments/9020938.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dtjones/commentrss.aspx?PostID=9020938</wfw:commentRss><wfw:comment>http://blogs.msdn.com/dtjones/rsscomments.aspx?PostID=9020938</wfw:comment><description>&lt;p&gt;The Beta of SQL2K5 SP3 is now available. You can download it &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=D22317E1-BC64-4936-A14B-7A632B50A4CA&amp;amp;displaylang=en"&gt;here&lt;/a&gt;. &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9020938" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dtjones/archive/tags/SQL+Server+2005/default.aspx">SQL Server 2005</category></item><item><title>Guarding Against SQL Injection</title><link>http://blogs.msdn.com/dtjones/archive/2008/06/30/guarding-against-sql-injection.aspx</link><pubDate>Mon, 30 Jun 2008 20:40:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8671967</guid><dc:creator>dtjones</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/dtjones/comments/8671967.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dtjones/commentrss.aspx?PostID=8671967</wfw:commentRss><wfw:comment>http://blogs.msdn.com/dtjones/rsscomments.aspx?PostID=8671967</wfw:comment><description>&lt;p&gt;Securing the database is only part of the security equation, a very important part, but still not the entire picture. DBAs need to educate their developer counterparts on developing secure applications which access the data tier. I would go as far as to put in place a security review process for any application that accesses data. As the owner of the data tier, if your application doesn't pass the security review it's not going to access &amp;quot;my&amp;quot; database. &lt;/p&gt;  &lt;p&gt;In conjunction with HP and the IIS team a new set of tools was recently released to help identify and defend against SQL injection attacks against ASP web sites. Microsoft Security Advisory 954462 (&lt;a title="http://www.microsoft.com/technet/security/advisory/954462.mspx" href="http://www.microsoft.com/technet/security/advisory/954462.mspx"&gt;http://www.microsoft.com/technet/security/advisory/954462.mspx&lt;/a&gt;) contains the details of the toolset. &lt;/p&gt;  &lt;p&gt;If you're responsible for the back-end data store that's accessed by an ASP web site you should download the toolset and run it against your ASP code. One last point to make, you should take these steps against applications that are externally accessible and internally accessible. It's unfortunate, but not every employee is trustworthy which means you need to guard against all attack vectors regardless of which side of the firewall they originate.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8671967" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dtjones/archive/tags/SQL+Server+2008/default.aspx">SQL Server 2008</category><category domain="http://blogs.msdn.com/dtjones/archive/tags/SQL+Server+2005/default.aspx">SQL Server 2005</category><category domain="http://blogs.msdn.com/dtjones/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/dtjones/archive/tags/Security/default.aspx">Security</category></item><item><title>SQL Server 2005 Best Practices Analyzer</title><link>http://blogs.msdn.com/dtjones/archive/2007/07/05/sql-server-2005-best-practices-analyzer.aspx</link><pubDate>Fri, 06 Jul 2007 03:04:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3716313</guid><dc:creator>dtjones</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/dtjones/comments/3716313.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dtjones/commentrss.aspx?PostID=3716313</wfw:commentRss><wfw:comment>http://blogs.msdn.com/dtjones/rsscomments.aspx?PostID=3716313</wfw:comment><description>&lt;p&gt;The Best Practices Analyzer for SQL Server 2005 is now available. &lt;/p&gt; &lt;p&gt;It's available for public download at &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=DA0531E4-E94C-4991-82FA-F0E3FBD05E63&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyId=DA0531E4-E94C-4991-82FA-F0E3FBD05E63&amp;amp;displaylang=en&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3716313" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dtjones/archive/tags/SQL+Server+2005/default.aspx">SQL Server 2005</category></item></channel></rss>