﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>SQL Server </title>
    <description>This blog will be used to post technical problems and solutions that we have encountered with SQL Server.</description>
    <link>http://elegantsoftwaresolutions.com/Blogs/tabid/816/BlogId/4/Default.aspx</link>
    <language>en-US</language>
    <managingEditor>tom.hundley@elegantsoftwaresolutions.com</managingEditor>
    <webMaster>tom.hundley@elegantsoftwaresolutions.com</webMaster>
    <pubDate>Sat, 05 Jul 2008 14:21:54 GMT</pubDate>
    <lastBuildDate>Sat, 05 Jul 2008 14:21:54 GMT</lastBuildDate>
    <docs>http://backend.userland.com/rss</docs>
    <generator>Blog RSS Generator Version 3.4.0.39853</generator>
    <item>
      <title>Truncate SQL Transaction Log and Shrink Database</title>
      <description>&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt; &lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;font face="Arial" color="#000000"&gt;I only need to do this every so often, but I always forget how to and end up looking it up.  Thus, I'm posting it here for reference.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt; &lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt; &lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New'; mso-no-proof: yes"&gt;USE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New'; mso-no-proof: yes"&gt; DatabaseName&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New'; mso-no-proof: yes"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New'; mso-no-proof: yes"&gt;BACKUP&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New'; mso-no-proof: yes"&gt; &lt;span style="color: fuchsia"&gt;LOG&lt;/span&gt; &lt;span style="color: gray"&gt;&lt;&lt;/span&gt;DatabaseName&lt;span style="color: gray"&gt;&gt;&lt;/span&gt; &lt;span style="color: blue"&gt;WITH&lt;/span&gt; &lt;span style="color: blue"&gt;TRUNCATE_ONLY&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;span style="font-size: 10pt; color: blue; line-height: 115%; font-family: 'Courier New'; mso-no-proof: yes"&gt;DBCC&lt;/span&gt;&lt;span style="font-size: 10pt; line-height: 115%; font-family: 'Courier New'; mso-no-proof: yes"&gt; SHRINKFILE&lt;span style="color: gray"&gt;(&lt;&lt;/span&gt;TransactionLogName&lt;span style="color: gray"&gt;&gt;,&lt;/span&gt; 1&lt;span style="color: gray"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 10pt; line-height: 115%; font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;span style="color: gray"&gt;
&lt;p&gt;&lt;span style="font-size: 10pt; color: blue; line-height: 115%; font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;font face="Arial" color="#000000"&gt;Tom Hundley&lt;br /&gt;
Elegant Software Solutions, LLC&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description>
      <link>http://elegantsoftwaresolutions.com/Blogs/tabid/816/EntryID/24/Default.aspx</link>
      <author>tom.hundley@elegantsoftwaresolutions.com</author>
      <comments>http://elegantsoftwaresolutions.com/Blogs/tabid/816/EntryID/24/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://elegantsoftwaresolutions.com/Default.aspx?tabid=816&amp;EntryID=24</guid>
      <pubDate>Sun, 15 Jun 2008 01:48:00 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://elegantsoftwaresolutions.com/DesktopModules/Blog/Trackback.aspx?id=24</trackback:ping>
    </item>
    <item>
      <title>Rebuild all Indexes in SQL Database</title>
      <description>&lt;p&gt;&lt;span style="font-size: 10pt; color: black; line-height: 115%; font-family: 'Arial','sans-serif'; mso-no-proof: yes"&gt;Here is a script to rebuild all of your indexes on your database.  I find that indexes are often ignored once an application moves to production.  It's a good idea to evaluate your usage patterns and setup automated maintenance jobs to proactively rebuild indexes before fragmentation has a chance to adversely effect performance.  This is especialy important if you are using guids as primary keys and don't move the clustered index to a more logically sequential column. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;span style="font-size: 10pt; color: green; font-family: " courier=""&gt;-- Show fragmentation for all tables&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: " courier=""&gt;EXEC&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt; &lt;span style="color: maroon"&gt;sp_MSforeachtable&lt;/span&gt; @command1&lt;span style="color: gray"&gt;=&lt;/span&gt;"print '?' DBCC SHOWCONTIG('?')"&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: green; font-family: " courier=""&gt;--Rebuild all indexes (note this method locks the tables while the indexes are being rebuilt)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: " courier=""&gt;USE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt; [myDatabase]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: " courier=""&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt; @TableName &lt;span style="color: blue"&gt;varchar&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;255&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: " courier=""&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt; TableCursor &lt;span style="color: blue"&gt;CURSOR&lt;/span&gt; &lt;span style="color: blue"&gt;FOR&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: " courier=""&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt; table_name &lt;span style="color: blue"&gt;FROM&lt;/span&gt; &lt;span style="color: green"&gt;information_schema.tables&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: " courier=""&gt;WHERE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt; table_type &lt;span style="color: gray"&gt;=&lt;/span&gt; &lt;span style="color: red"&gt;'base table'&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: " courier=""&gt;OPEN&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt; TableCursor &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: " courier=""&gt;FETCH&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt; &lt;span style="color: blue"&gt;NEXT&lt;/span&gt; &lt;span style="color: blue"&gt;FROM&lt;/span&gt; TableCursor &lt;span style="color: blue"&gt;INTO&lt;/span&gt; @TableName &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: " courier=""&gt;WHILE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt; &lt;span style="color: fuchsia"&gt;@@FETCH_STATUS&lt;/span&gt; &lt;span style="color: gray"&gt;=&lt;/span&gt; 0 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: " courier=""&gt;BEGIN&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: " courier=""&gt;DBCC&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt; DBREINDEX&lt;span style="color: gray"&gt;(&lt;/span&gt;@TableName&lt;span style="color: gray"&gt;,&lt;/span&gt;&lt;span style="color: red"&gt;' '&lt;/span&gt;&lt;span style="color: gray"&gt;,&lt;/span&gt;90&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: " courier=""&gt;FETCH&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt; &lt;span style="color: blue"&gt;NEXT&lt;/span&gt; &lt;span style="color: blue"&gt;FROM&lt;/span&gt; TableCursor &lt;span style="color: blue"&gt;INTO&lt;/span&gt; @TableName &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: " courier=""&gt;END&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: " courier=""&gt;CLOSE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt; TableCursor &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: " courier=""&gt;DEALLOCATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: " courier=""&gt; TableCursor&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;font face="Calibri" size="3"&gt; &lt;/font&gt; &lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 10pt; color: blue; line-height: 115%; font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;font face="Arial" color="#000000"&gt;Tom Hundley&lt;br /&gt;
Elegant Software Solutions, LLC&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 10pt; color: blue; line-height: 115%; font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;font face="Arial" color="#000000"&gt;Here is a script to rebuild all of your indexes on your database.  I find that indexes are often ignored once an application moves to production.  It's a good idea to evaluate your usage patterns and setup automated maintenance jobs to proactively rebuild indexes before fragmentation has a chance to adversely effect performance.  This is especialy important if you are using guids as primary keys and don't move the clustered index to a more logically sequential column.  &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;</description>
      <link>http://elegantsoftwaresolutions.com/Blogs/tabid/816/EntryID/23/Default.aspx</link>
      <author>tom.hundley@elegantsoftwaresolutions.com</author>
      <comments>http://elegantsoftwaresolutions.com/Blogs/tabid/816/EntryID/23/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://elegantsoftwaresolutions.com/Default.aspx?tabid=816&amp;EntryID=23</guid>
      <pubDate>Sun, 15 Jun 2008 01:39:00 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://elegantsoftwaresolutions.com/DesktopModules/Blog/Trackback.aspx?id=23</trackback:ping>
    </item>
    <item>
      <title>Connecting to SQL Server 2005 with SSL</title>
      <description>&lt;p&gt;Did you know you can connect to SQLServer&amp;#160;from your application using SSL?&lt;/p&gt;</description>
      <link>http://elegantsoftwaresolutions.com/Blogs/tabid/816/EntryID/14/Default.aspx</link>
      <author>tom.hundley@elegantsoftwaresolutions.com</author>
      <comments>http://elegantsoftwaresolutions.com/Blogs/tabid/816/EntryID/14/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://elegantsoftwaresolutions.com/Default.aspx?tabid=816&amp;EntryID=14</guid>
      <pubDate>Sun, 03 Feb 2008 21:12:00 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://elegantsoftwaresolutions.com/DesktopModules/Blog/Trackback.aspx?id=14</trackback:ping>
    </item>
    <item>
      <title>Microsoft SQL Sever 2005 Encryption</title>
      <description>&lt;p&gt;Quick reference to the Microsoft SQL Server 2005 Whitepaper&lt;/p&gt;</description>
      <link>http://elegantsoftwaresolutions.com/Blogs/tabid/816/EntryID/13/Default.aspx</link>
      <author>tom.hundley@elegantsoftwaresolutions.com</author>
      <comments>http://elegantsoftwaresolutions.com/Blogs/tabid/816/EntryID/13/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://elegantsoftwaresolutions.com/Default.aspx?tabid=816&amp;EntryID=13</guid>
      <pubDate>Sun, 03 Feb 2008 21:10:00 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://elegantsoftwaresolutions.com/DesktopModules/Blog/Trackback.aspx?id=13</trackback:ping>
    </item>
    <item>
      <title>Editing existing SSIS Packages in SQL Server 2005</title>
      <description>Viewing and editing an existing SSIS package is limited to SQL Server Business Intelligence Development Studio (SSBIDS) or Visual Studio 2005 Team Suite (VSTS). </description>
      <link>http://elegantsoftwaresolutions.com/Blogs/tabid/816/EntryID/4/Default.aspx</link>
      <author>tom.hundley@elegantsoftwaresolutions.com</author>
      <comments>http://elegantsoftwaresolutions.com/Blogs/tabid/816/EntryID/4/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://elegantsoftwaresolutions.com/Default.aspx?tabid=816&amp;EntryID=4</guid>
      <pubDate>Sat, 21 Apr 2007 05:44:00 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://elegantsoftwaresolutions.com/DesktopModules/Blog/Trackback.aspx?id=4</trackback:ping>
    </item>
    <item>
      <title> Finding SSIS Packages in SQL Server Management Studio (SSMS)</title>
      <description>I used SQL Server Integration Services (SSIS) Import &amp; Export Wizard from SQL Server Management Studio (SSMS) to create an SSIS package and saved it to the server.  I beat my head against the wall trying to find it via SSMS after I saved it.</description>
      <link>http://elegantsoftwaresolutions.com/Blogs/tabid/816/EntryID/3/Default.aspx</link>
      <author>tom.hundley@elegantsoftwaresolutions.com</author>
      <comments>http://elegantsoftwaresolutions.com/Blogs/tabid/816/EntryID/3/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://elegantsoftwaresolutions.com/Default.aspx?tabid=816&amp;EntryID=3</guid>
      <pubDate>Sat, 21 Apr 2007 05:42:00 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://elegantsoftwaresolutions.com/DesktopModules/Blog/Trackback.aspx?id=3</trackback:ping>
    </item>
  </channel>
</rss>