<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>High Availability</title>
        <link>http://weblogs.sqlteam.com/geoffh/category/294.aspx</link>
        <description>People, Process, and Technology to keep your systems running.</description>
        <language>en-US</language>
        <copyright>Geoff N. Hiten</copyright>
        <managingEditor>sqlcraftsman@gmail.com</managingEditor>
        <generator>Subtext Version 1.9.4.0</generator>
        <item>
            <title>Update: SQL 2005 Build 3186 Cluster problem </title>
            <link>http://weblogs.sqlteam.com/geoffh/archive/2007/11/12/Update-SQL-2005-Build-3186-Cluster-problem.aspx</link>
            <description>&lt;p&gt;Microsoft does not have a complete resolution for this problem yet, but they have found some more details.  Evidently the problem with SQL Agent failure only occurs on systems using a domain admin account for the SQL Agent Service account.  Microsoft is not 100% sure yet, so this is just a preliminary finding.  However, it does match my own personal experiences.  Worst Practices always has a cost.  Several DBAs just found that out the hard way.  Just as a reminder, this problem only occurs on x64 clusters using SQL Server 2005 build 3186 and higher.&lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/geoffh/aggbug/60396.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Geoff N. Hiten</dc:creator>
            <guid>http://weblogs.sqlteam.com/geoffh/archive/2007/11/12/Update-SQL-2005-Build-3186-Cluster-problem.aspx</guid>
            <pubDate>Mon, 12 Nov 2007 21:09:24 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/geoffh/archive/2007/11/12/Update-SQL-2005-Build-3186-Cluster-problem.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/geoffh/comments/commentRss/60396.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/geoffh/services/trackbacks/60396.aspx</trackback:ping>
        </item>
        <item>
            <title>Online Reindex = ON</title>
            <link>http://weblogs.sqlteam.com/geoffh/archive/2007/11/01/Online-Reindex--ON.aspx</link>
            <description>&lt;p&gt;For the past several editions, SQL Books On-Line (BOL) has helpfully included a script to rebuild or defragment (since 2000) an index. Being Microsoft, this script is NOT located under the reindex or defragmentation topic, it is included in the fragmentation analysis section. For SQL 2000, this is DBCC SHOWCONTIG. For SQL 2005, they rewrote it to use the new system views and stashed it under sys.dm_db_physical_stats. It also uses the new ALTER INDEX command rather than the older DBCC DBREINDEX or DBCC INDEXDEFRAG command. However, this script does not allow you to take advantage of online indexing &lt;/p&gt;
&lt;p&gt;My first attempt to modify the script consisted of dropping the defragmentation option and simply adding a WITH ONLINE = ON line to the script. As with most quick and dirty mods, this failed miserably. I soon discovered that some indexes cannot be rebuilt online. There are two conditions that will prevent online reindexing, both of which involve BLOB data types: &lt;/p&gt;
&lt;p&gt;&lt;span style="COLOR: red"&gt;You cannot online reindex a non-clustered index that contains a BLOB column. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="COLOR: red"&gt;You cannot online reindex a clustered index of a table that contains a BLOB column. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Pretty straightforward, or so it seems. The code to identify BLOB columns from an index is a bit tricky, but not too impossible. I used actual data type names rather than the internal data type IDs to make the code more readable. I also added a filter condition to remove "trivial" sized indexes. These are typically allocated into mixed extents and do not respond to defragmentation. There is no real harm in including them, but they clutter up the result set when troubleshooting. I kept tweaking the number until I got it as low as possible without an index reappearing in subsequent runs. The test platform was a Microsoft CRM implementation. For those unfamiliar with the table design of MSCRM, it uses GUIDs as primary keys and accepts the default of clustering the primary key. This makes for a nicely fragmented database to test, especially if there is a lot of insert and delete activity. &lt;/p&gt;
&lt;p&gt;So without further ado, here is the modified BOL code that allows for scripting online index rebuilds. &lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: Courier New"&gt;-- Adapted from BOL script by Geoff N. Hiten. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;USE&lt;/span&gt; &lt;span style="COLOR: gray"&gt;&amp;lt;&lt;/span&gt;Your &lt;span style="COLOR: blue"&gt;Database&lt;/span&gt; &lt;span style="COLOR: blue"&gt;name&lt;/span&gt; here&lt;span style="COLOR: gray"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;GO &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: Courier New"&gt;-- Ensure a USE &amp;lt;databasename&amp;gt; statement has been executed first. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;SET&lt;/span&gt; &lt;span style="COLOR: blue"&gt;NOCOUNT&lt;/span&gt; &lt;span style="COLOR: blue"&gt;ON&lt;/span&gt;&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;DECLARE&lt;/span&gt; @objectid &lt;span style="COLOR: blue"&gt;int&lt;/span&gt;&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;DECLARE&lt;/span&gt; @indexid &lt;span style="COLOR: blue"&gt;int&lt;/span&gt;&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;DECLARE&lt;/span&gt; @partitioncount &lt;span style="COLOR: blue"&gt;bigint&lt;/span&gt;&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;DECLARE&lt;/span&gt; @schemaname &lt;span style="COLOR: blue"&gt;nvarchar&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;130&lt;span style="COLOR: gray"&gt;);&lt;/span&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;DECLARE&lt;/span&gt; @objectname &lt;span style="COLOR: blue"&gt;nvarchar&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;130&lt;span style="COLOR: gray"&gt;);&lt;/span&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;DECLARE&lt;/span&gt; @indexname &lt;span style="COLOR: blue"&gt;nvarchar&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;130&lt;span style="COLOR: gray"&gt;);&lt;/span&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;DECLARE&lt;/span&gt; @partitionnum &lt;span style="COLOR: blue"&gt;bigint&lt;/span&gt;&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;DECLARE&lt;/span&gt; @partitions &lt;span style="COLOR: blue"&gt;bigint&lt;/span&gt;&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;DECLARE&lt;/span&gt; @frag &lt;span style="COLOR: blue"&gt;float&lt;/span&gt;&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;DECLARE&lt;/span&gt; @command &lt;span style="COLOR: blue"&gt;nvarchar&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;4000&lt;span style="COLOR: gray"&gt;);&lt;/span&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;DECLARE&lt;/span&gt; @HasBlobColumn &lt;span style="COLOR: blue"&gt;int&lt;/span&gt;&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;DECLARE&lt;/span&gt; @MaxFragmentation &lt;span style="COLOR: blue"&gt;int &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;DECLARE&lt;/span&gt; @TrivialPageCount &lt;span style="COLOR: blue"&gt;int &lt;/span&gt;&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 New"&gt;-- Tuning constants &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;SET&lt;/span&gt; @MAxFragmentation &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; 10 &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;SET&lt;/span&gt; @TrivialPageCount &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; 12 &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 New"&gt;-- Conditionally select tables and indexes from the sys.dm_db_index_physical_stats function &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: Courier New"&gt;-- and convert object and index IDs to names. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;SELECT&lt;/span&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: fuchsia"&gt;object_id&lt;/span&gt; &lt;span style="COLOR: blue"&gt;AS&lt;/span&gt; objectid&lt;span style="COLOR: gray"&gt;, &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;index_id &lt;span style="COLOR: blue"&gt;AS&lt;/span&gt; indexid&lt;span style="COLOR: gray"&gt;, &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;partition_number &lt;span style="COLOR: blue"&gt;AS&lt;/span&gt; partitionnum&lt;span style="COLOR: gray"&gt;, &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;avg_fragmentation_in_percent &lt;span style="COLOR: blue"&gt;AS&lt;/span&gt; frag &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;INTO&lt;/span&gt; #work_to_do &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;FROM&lt;/span&gt; sys.dm_db_index_physical_stats &lt;span style="COLOR: gray"&gt;(&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;DB_ID&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(),&lt;/span&gt; &lt;span style="COLOR: gray"&gt;NULL,&lt;/span&gt; &lt;span style="COLOR: gray"&gt;NULL&lt;/span&gt; &lt;span style="COLOR: gray"&gt;,&lt;/span&gt; &lt;span style="COLOR: gray"&gt;NULL,&lt;/span&gt; &lt;span style="COLOR: red"&gt;'LIMITED'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;WHERE&lt;/span&gt; avg_fragmentation_in_percent &lt;span style="COLOR: gray"&gt;&amp;gt;&lt;/span&gt; @MaxFragmentation &lt;span style="COLOR: green"&gt;-- arbitrary threshold. YMMV &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;    &lt;span style="COLOR: gray"&gt;AND&lt;/span&gt; index_id &lt;span style="COLOR: gray"&gt;&amp;gt;&lt;/span&gt; 0 &lt;span style="COLOR: green"&gt;-- cannot defrag a heap &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;    &lt;span style="COLOR: gray"&gt;and&lt;/span&gt; page_count &lt;span style="COLOR: gray"&gt;&amp;gt;&lt;/span&gt; @TrivialPageCount &lt;span style="COLOR: green"&gt;-- ignore trivial sized indexes &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: Courier New"&gt;-- Declare the cursor for the list of partitions to be processed. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;DECLARE&lt;/span&gt; partitions &lt;span style="COLOR: blue"&gt;CURSOR&lt;/span&gt; &lt;span style="COLOR: blue"&gt;FOR&lt;/span&gt; &lt;span style="COLOR: blue"&gt;SELECT&lt;/span&gt; &lt;span style="COLOR: gray"&gt;*&lt;/span&gt; &lt;span style="COLOR: blue"&gt;FROM&lt;/span&gt; #work_to_do&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&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 New"&gt;-- Open the cursor. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;OPEN&lt;/span&gt; partitions&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&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 New"&gt;-- Loop through the partitions. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;WHILE&lt;/span&gt; &lt;span style="COLOR: gray"&gt;(&lt;/span&gt;1&lt;span style="COLOR: gray"&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; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;BEGIN&lt;/span&gt;&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;FETCH&lt;/span&gt; &lt;span style="COLOR: blue"&gt;NEXT &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;FROM&lt;/span&gt; partitions &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;INTO&lt;/span&gt; @objectid&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; @indexid&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; @partitionnum&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; @frag&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;IF&lt;/span&gt; &lt;span style="COLOR: fuchsia"&gt;@@FETCH_STATUS&lt;/span&gt; &lt;span style="COLOR: gray"&gt;&amp;lt;&lt;/span&gt; 0 &lt;span style="COLOR: blue"&gt;BREAK&lt;/span&gt;&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;        &lt;span style="COLOR: blue"&gt;Set&lt;/span&gt; @HasBlobColumn &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; 0 &lt;span style="COLOR: green"&gt;-- reinitialize &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;SELECT&lt;/span&gt; @objectname &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; &lt;span style="COLOR: fuchsia"&gt;QUOTENAME&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;o&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;name&lt;span style="COLOR: gray"&gt;),&lt;/span&gt; @schemaname &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; &lt;span style="COLOR: fuchsia"&gt;QUOTENAME&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;s&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;name&lt;span style="COLOR: gray"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;            &lt;span style="COLOR: blue"&gt;FROM&lt;/span&gt; &lt;span style="COLOR: green"&gt;sys.objects&lt;/span&gt; &lt;span style="COLOR: blue"&gt;AS&lt;/span&gt; o &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;            &lt;span style="COLOR: gray"&gt;JOIN&lt;/span&gt; &lt;span style="COLOR: green"&gt;sys.schemas&lt;/span&gt; &lt;span style="COLOR: blue"&gt;as&lt;/span&gt; s &lt;span style="COLOR: blue"&gt;ON&lt;/span&gt; s&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;schema_id&lt;/span&gt; &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; o&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;schema_id &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;            &lt;span style="COLOR: blue"&gt;WHERE&lt;/span&gt; o&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;object_id&lt;/span&gt; &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; @objectid&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;SELECT&lt;/span&gt; @indexname &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; &lt;span style="COLOR: fuchsia"&gt;QUOTENAME&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;&lt;span style="COLOR: blue"&gt;name&lt;/span&gt;&lt;span style="COLOR: gray"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;            &lt;span style="COLOR: blue"&gt;FROM&lt;/span&gt; &lt;span style="COLOR: green"&gt;sys.indexes &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;            &lt;span style="COLOR: blue"&gt;WHERE&lt;/span&gt; &lt;span style="COLOR: fuchsia"&gt;object_id&lt;/span&gt; &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; @objectid &lt;span style="COLOR: gray"&gt;AND&lt;/span&gt; index_id &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; @indexid&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;SELECT&lt;/span&gt; @partitioncount &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; &lt;span style="COLOR: fuchsia"&gt;count&lt;/span&gt; &lt;span style="COLOR: gray"&gt;(*) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;            &lt;span style="COLOR: blue"&gt;FROM&lt;/span&gt; &lt;span style="COLOR: green"&gt;sys.partitions &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;            &lt;span style="COLOR: blue"&gt;WHERE&lt;/span&gt; &lt;span style="COLOR: fuchsia"&gt;object_id&lt;/span&gt; &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; @objectid &lt;span style="COLOR: gray"&gt;AND&lt;/span&gt; index_id &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; @indexid&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;        &lt;span style="COLOR: green"&gt;-- Check for BLOB columns &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;        &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; @indexid &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; 1 &lt;span style="COLOR: green"&gt;-- only check here for clustered indexes ANY blob column on the table counts &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;            &lt;span style="COLOR: blue"&gt;Select&lt;/span&gt; @HasBlobColumn &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; &lt;span style="COLOR: blue"&gt;case&lt;/span&gt; &lt;span style="COLOR: blue"&gt;when&lt;/span&gt; &lt;span style="COLOR: fuchsia"&gt;max&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;so&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;object_ID&lt;/span&gt;&lt;span style="COLOR: gray"&gt;)&lt;/span&gt; &lt;span style="COLOR: gray"&gt;IS&lt;/span&gt; &lt;span style="COLOR: gray"&gt;NULL&lt;/span&gt; &lt;span style="COLOR: blue"&gt;then&lt;/span&gt; 0 &lt;span style="COLOR: blue"&gt;else&lt;/span&gt; 1 &lt;span style="COLOR: blue"&gt;end &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                &lt;span style="COLOR: blue"&gt;From&lt;/span&gt; &lt;span style="COLOR: green"&gt;sys.objects&lt;/span&gt; SO &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                &lt;span style="COLOR: gray"&gt;inner&lt;/span&gt; &lt;span style="COLOR: gray"&gt;join&lt;/span&gt; &lt;span style="COLOR: green"&gt;sys.columns&lt;/span&gt; SC &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                    &lt;span style="COLOR: blue"&gt;on&lt;/span&gt; SO&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;Object_id&lt;/span&gt; &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; SC&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;object_id &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                &lt;span style="COLOR: gray"&gt;inner&lt;/span&gt; &lt;span style="COLOR: gray"&gt;join&lt;/span&gt; &lt;span style="COLOR: green"&gt;sys.types&lt;/span&gt; ST &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                    &lt;span style="COLOR: blue"&gt;on&lt;/span&gt; SC&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;system_type_id &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; ST&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;system_type_id &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                    &lt;span style="COLOR: gray"&gt;and&lt;/span&gt; ST&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;name &lt;span style="COLOR: gray"&gt;in&lt;/span&gt; &lt;span style="COLOR: gray"&gt;(&lt;/span&gt;&lt;span style="COLOR: red"&gt;'text'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; &lt;span style="COLOR: red"&gt;'ntext'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; &lt;span style="COLOR: red"&gt;'image'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; &lt;span style="COLOR: red"&gt;'varchar(max)'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; &lt;span style="COLOR: red"&gt;'nvarchar(max)'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; &lt;span style="COLOR: red"&gt;'varbinary(max)'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; &lt;span style="COLOR: red"&gt;'xml'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                &lt;span style="COLOR: blue"&gt;where&lt;/span&gt; SO&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;Object_ID&lt;/span&gt; &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; @objectID &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;            &lt;span style="COLOR: blue"&gt;else&lt;/span&gt; &lt;span style="COLOR: green"&gt;-- nonclustered. Only need to check if indexed column is a BLOB &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;            &lt;span style="COLOR: blue"&gt;Select&lt;/span&gt; @HasBlobColumn &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; &lt;span style="COLOR: blue"&gt;case&lt;/span&gt; &lt;span style="COLOR: blue"&gt;when&lt;/span&gt; &lt;span style="COLOR: fuchsia"&gt;max&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;so&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;object_ID&lt;/span&gt;&lt;span style="COLOR: gray"&gt;)&lt;/span&gt; &lt;span style="COLOR: gray"&gt;IS&lt;/span&gt; &lt;span style="COLOR: gray"&gt;NULL&lt;/span&gt; &lt;span style="COLOR: blue"&gt;then&lt;/span&gt; 0 &lt;span style="COLOR: blue"&gt;else&lt;/span&gt; 1 &lt;span style="COLOR: blue"&gt;end &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                &lt;span style="COLOR: blue"&gt;from&lt;/span&gt; &lt;span style="COLOR: green"&gt;sys.objects&lt;/span&gt; SO &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                &lt;span style="COLOR: gray"&gt;inner&lt;/span&gt; &lt;span style="COLOR: gray"&gt;join&lt;/span&gt; &lt;span style="COLOR: green"&gt;sys.index_columns&lt;/span&gt; SIC &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                    &lt;span style="COLOR: blue"&gt;on&lt;/span&gt; SO&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;Object_ID&lt;/span&gt; &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; SIC&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;object_id &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                &lt;span style="COLOR: gray"&gt;inner&lt;/span&gt; &lt;span style="COLOR: gray"&gt;join&lt;/span&gt; &lt;span style="COLOR: green"&gt;sys.Indexes&lt;/span&gt; SI &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                    &lt;span style="COLOR: blue"&gt;on&lt;/span&gt; SO&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;Object_ID&lt;/span&gt; &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; SI&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;Object_ID &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                    &lt;span style="COLOR: gray"&gt;and&lt;/span&gt; SIC&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;index_id &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; SI&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;index_id &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                &lt;span style="COLOR: gray"&gt;inner&lt;/span&gt; &lt;span style="COLOR: gray"&gt;join&lt;/span&gt; &lt;span style="COLOR: green"&gt;sys.columns&lt;/span&gt; SC &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                    &lt;span style="COLOR: blue"&gt;on&lt;/span&gt; SO&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;Object_id&lt;/span&gt; &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; SC&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;object_id &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                    &lt;span style="COLOR: gray"&gt;and&lt;/span&gt; SIC&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;Column_id &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; SC&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;column_id &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                &lt;span style="COLOR: gray"&gt;inner&lt;/span&gt; &lt;span style="COLOR: gray"&gt;join&lt;/span&gt; &lt;span style="COLOR: green"&gt;sys.types&lt;/span&gt; ST &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                    &lt;span style="COLOR: blue"&gt;on&lt;/span&gt; SC&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;system_type_id &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; ST&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;system_type_id &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                    &lt;span style="COLOR: gray"&gt;and&lt;/span&gt; ST&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;name &lt;span style="COLOR: gray"&gt;in&lt;/span&gt; &lt;span style="COLOR: gray"&gt;(&lt;/span&gt;&lt;span style="COLOR: red"&gt;'text'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; &lt;span style="COLOR: red"&gt;'ntext'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; &lt;span style="COLOR: red"&gt;'image'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; &lt;span style="COLOR: red"&gt;'varchar(max)'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; &lt;span style="COLOR: red"&gt;'nvarchar(max)'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; &lt;span style="COLOR: red"&gt;'varbinary(max)'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; &lt;span style="COLOR: red"&gt;'xml'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;                &lt;span style="COLOR: blue"&gt;where&lt;/span&gt; SO&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;Object_ID&lt;/span&gt; &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; @objectID &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;        &lt;span style="COLOR: blue"&gt;SET&lt;/span&gt; @command &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; N&lt;span style="COLOR: red"&gt;'ALTER INDEX '&lt;/span&gt; &lt;span style="COLOR: gray"&gt;+&lt;/span&gt; @indexname &lt;span style="COLOR: gray"&gt;+&lt;/span&gt; N&lt;span style="COLOR: red"&gt;' ON '&lt;/span&gt; &lt;span style="COLOR: gray"&gt;+&lt;/span&gt; @schemaname &lt;span style="COLOR: gray"&gt;+&lt;/span&gt; N&lt;span style="COLOR: red"&gt;'.'&lt;/span&gt; &lt;span style="COLOR: gray"&gt;+&lt;/span&gt; @objectname &lt;span style="COLOR: gray"&gt;+&lt;/span&gt; N&lt;span style="COLOR: red"&gt;' REBUILD'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;        &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; @HasBlobColumn &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; 1 &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;            &lt;span style="COLOR: blue"&gt;Set&lt;/span&gt; @command &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; @command &lt;span style="COLOR: gray"&gt;+&lt;/span&gt; N&lt;span style="COLOR: red"&gt;' WITH( SORT_IN_TEMPDB = ON) ' &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;        &lt;span style="COLOR: blue"&gt;else &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;            &lt;span style="COLOR: blue"&gt;Set&lt;/span&gt; @command &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; @command &lt;span style="COLOR: gray"&gt;+&lt;/span&gt; N&lt;span style="COLOR: red"&gt;' WITH( ONLINE = ON, SORT_IN_TEMPDB = ON) ' &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;IF&lt;/span&gt; @partitioncount &lt;span style="COLOR: gray"&gt;&amp;gt;&lt;/span&gt; 1 &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;SET&lt;/span&gt; @command &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; @command &lt;span style="COLOR: gray"&gt;+&lt;/span&gt; N&lt;span style="COLOR: red"&gt;' PARTITION='&lt;/span&gt; &lt;span style="COLOR: gray"&gt;+&lt;/span&gt; &lt;span style="COLOR: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;@partitionnum &lt;span style="COLOR: blue"&gt;AS&lt;/span&gt; &lt;span style="COLOR: blue"&gt;nvarchar&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;10&lt;span style="COLOR: gray"&gt;)); &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;PRINT&lt;/span&gt; N&lt;span style="COLOR: red"&gt;'Executing: '&lt;/span&gt; &lt;span style="COLOR: gray"&gt;+&lt;/span&gt; @command &lt;span style="COLOR: gray"&gt;+&lt;/span&gt; &lt;span style="COLOR: red"&gt;' Has Blob = '&lt;/span&gt; &lt;span style="COLOR: gray"&gt;+&lt;/span&gt; &lt;span style="COLOR: fuchsia"&gt;convert&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;&lt;span style="COLOR: blue"&gt;nvarchar&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;2&lt;span style="COLOR: gray"&gt;),&lt;/span&gt;@HasBlobColumn&lt;span style="COLOR: gray"&gt;); &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;        &lt;span style="COLOR: blue"&gt;EXEC&lt;/span&gt; &lt;span style="COLOR: gray"&gt;(&lt;/span&gt;@command&lt;span style="COLOR: gray"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: Courier New"&gt;-- PRINT N'Executing: ' + @command; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;END&lt;/span&gt;&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&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 New"&gt;-- Close and deallocate the cursor. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;CLOSE&lt;/span&gt; partitions&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;DEALLOCATE&lt;/span&gt; partitions&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&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 New"&gt;-- Drop the temporary table. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;DROP&lt;/span&gt; &lt;span style="COLOR: blue"&gt;TABLE&lt;/span&gt; #work_to_do&lt;span style="COLOR: gray"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;GO&lt;/span&gt; &lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/geoffh/aggbug/60389.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Geoff N. Hiten</dc:creator>
            <guid>http://weblogs.sqlteam.com/geoffh/archive/2007/11/01/Online-Reindex--ON.aspx</guid>
            <pubDate>Thu, 01 Nov 2007 13:35:00 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/geoffh/archive/2007/11/01/Online-Reindex--ON.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/geoffh/comments/commentRss/60389.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/geoffh/services/trackbacks/60389.aspx</trackback:ping>
        </item>
        <item>
            <title>SQL 2005 Build 3186 Cluster problem</title>
            <link>http://weblogs.sqlteam.com/geoffh/archive/2007/10/11/Warning--Danger-WIll-Robinson.aspx</link>
            <description>&lt;p&gt;SQL 2005 Build 3186 has a major negative side effect on x64 clusters.  Installing it pretty much kills the SQL Agent..  The workaround is to enable unconstrained delegation for the machine and the service accounts.  Not exactly a best practices security setting, but necessary.  For now, if you are on an x64 cluster and don't have a compelling reason to install this hotfix, you may want to wait until this issue gets resolved.&lt;/p&gt;
&lt;p&gt;Here is the MSDN thread discussing the problem and the workaround:&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2242421&amp;amp;SiteID=1"&gt;http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2242421&amp;amp;SiteID=1&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt; UPDATE:  &lt;/strong&gt;Build 3200 (Cumulative Update 4) has the same issue.  Evidently this bug is due to a complex interaction between SQL and Windows Security.  I would not expect a quick fix.  I can confim that this definitely has major visibility and resource assignment within Microsoft.  It just isn't an easy problem to solve.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/geoffh/aggbug/60368.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Geoff N. Hiten</dc:creator>
            <guid>http://weblogs.sqlteam.com/geoffh/archive/2007/10/11/Warning--Danger-WIll-Robinson.aspx</guid>
            <pubDate>Thu, 11 Oct 2007 17:53:35 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/geoffh/archive/2007/10/11/Warning--Danger-WIll-Robinson.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/geoffh/comments/commentRss/60368.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/geoffh/services/trackbacks/60368.aspx</trackback:ping>
        </item>
        <item>
            <title>Patches!  We don’t need no stinkeen’ Patches!</title>
            <link>http://weblogs.sqlteam.com/geoffh/archive/2007/10/09/Patches--We-dont-need-no-stinkeen-Patches.aspx</link>
            <description>&lt;div style="MARGIN: 0in 0in 10pt"&gt;Well, yes. Actually you do. Patching a SQL Server cluster sounds like a complex endeavor, but it is really a lot simpler than people think. Much of the confusion is due to SQL 2000 and SQL 2005 having slightly different behaviors when it comes to patching. Also, with Clustering now available in Standard Edition, more DBAs find themselves caring for the first cluster in their organization. “Learn as you go” is not nearly as fun as it sounds.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;The first rule of patching is to test. Make sure the patches work in a test environment, both with patches for the OS and for SQL. Given the history of unstable SQL Service Packs, I have to suggest waiting for a few weeks after a SP is released to make sure nothing important got broken. The SQL team is very much aware of their past shortcomings in that area and has started to fix the entire SQL servicing model. It will be a while before we see the fruits of those efforts, so for the time being let someone else be the (insert politically correct ethnic minority here) mine detector.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Regardless of the SQL version, the OS will need patching from time to time. Balancing the need to keep a system secure from newly discovered vulnerabilities with the desire to have a stable platform is tricky. You want to stay up-to-date, but not TOO up-to-date. Again, testing is the key. Never deploy anything you have not tested onto a highly-available platform. As such, I never allow Windows or Microsoft update to automatically patch any database host server. I manually inspect and apply patches, although I still use the update tool to recommend and track updates. Only apply patches during a defined maintenance window, even if you just patch a currently inactive node. That way if something goes wrong, you don’t have to explain why you took the accounting server down during month-end closing. If you have an N-1 cluster (N nodes, N-1 instances) then you will always have a free node to start on. Apply the OS patches and reboot if necessary. Failover and repeat as necessary until all nodes are done. OS patches are never cluster aware so everything is in the context of the local node. If you don’t have a free node, say with a two-node, two instance system, then I recommend clearing one node by moving the SQL instances. Always OS patch a node when it is “empty”. Don’t forget to move the Cluster and MSTDC groups too.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;SQL 2000 Service Packs and Hotfixes are always cluster-wide for all components. Always start on the node hosting the instance you want to patch. SQL 2000 patches (both Service Packs and Hotfixes) only work on one instance at a time.   Pay careful attention to the message boxes indicating completion. They may tell you to reboot the remote node(s). Always reboot when the installer tells you to. The system may be unstable or not failover properly if you do not.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;SQL 2005 is a lot trickier. Only the Database Engine and Analysis services are cluster-wide. Everything else is local to the node.  So, when you run the installer you may get different options on what to upgrade. If there are one or more instances on the node you execute the update on, you can update those instances. Otherwise you get to update just the local components. Note that this is new for SQL 2005. Before, you had to patch each instance separately. You can update the non-clustered components at the same time you update the cluster-aware components, but only for components on the local node. This is NOT clearly indicated by installer. You must go to each node and update SSIS, workstation components, Notification Services and Reporting Services.   Of course, you shouldn’t be running Reporting Services on a failover cluster, but that is another discussion.   Fortunately, the installer does have some smarts and will show you what has already been updated so you don’t have to re-run the update for that component. This makes it safe to run the updater if you lose track or have inherited a system where you are not sure what components are at what revision level. Service Packs and Hotfixes both work this same way. And yes, you need to update client tools on all cluster nodes and your workstations. Again, pay attention to the closing messages and reboot when told. Bad Things™ will happen if you don’t.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt; &lt;/div&gt;&lt;img src="http://weblogs.sqlteam.com/geoffh/aggbug/60363.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Geoff N. Hiten</dc:creator>
            <guid>http://weblogs.sqlteam.com/geoffh/archive/2007/10/09/Patches--We-dont-need-no-stinkeen-Patches.aspx</guid>
            <pubDate>Tue, 09 Oct 2007 21:31:18 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/geoffh/archive/2007/10/09/Patches--We-dont-need-no-stinkeen-Patches.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/geoffh/comments/commentRss/60363.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/geoffh/services/trackbacks/60363.aspx</trackback:ping>
        </item>
        <item>
            <title>To Cluster or Not to Cluster, That SSIS the Question</title>
            <link>http://weblogs.sqlteam.com/geoffh/archive/2007/10/04/To-Cluster-or-Not-to-Cluster-That-SSIS-the-Question.aspx</link>
            <description>&lt;p&gt;Clustering and SSIS have a stormy relationship at best. What you think you get after installing SQL and SSIS on a cluster is not always what you expected. For SQL 2000, the installer was cluster-aware on every component. Tools, code, everything got loaded on all nodes. Now, we aren't so lucky. Only SQL and SSAS install cluster-wide (or at least to all specified nodes). Client tools and most importantly SSIS only install to the local node. In practice, this often means a successful cluster install can leave a DBA with only one node capable of running SSIS packages. What is worse is that the first time this gets noticed is when a production system fails over and SSIS is nowhere to be found. So the first good reason to cluster SSIS is to make sure it actually works on all nodes correctly. &lt;/p&gt;
&lt;p&gt;Another good reason to cluster SSIS is if any of your SSIS packages use a clustered resource such as a file share on one of the SQL data drives. You either have to create a clustered file share OR cluster SSIS. I prefer clustering SSIS since it keeps things simpler from a developer and a DBA perspective. Plus, the SQL installer tends to dislike anything "extra" on the core SQL cluster resources. &lt;/p&gt;
&lt;p&gt;Microsoft warns that clustering SSIS is not recommended and not supported, but then tells exactly how to do it. Personally, I think they just didn't have time to build this logic into the installer. I have had no problems running clustered SSIS. I have had several issues running SSIS on a cluster without clustering SSIS itself. Either way, here is the link to the TechNet article: &lt;/p&gt;
&lt;p&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms345193.aspx"&gt;http://technet.microsoft.com/en-us/library/ms345193.aspx&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;There is one warning about clustering SSIS that I do need to emphasize. Since the SSIS install routines don't support clustering directly, neither do the Service Pack or Hotfix installers. You have to run them independently on each node, preferably with the SSIS service active on that node. This does increase the downtime for applying updates. The alternative is to "uncluster" SSIS, apply the updates, then "recluster" SSIS. Dunno about you, but I just had an ugly flashback to SQL 7.0. &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/geoffh/aggbug/60356.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Geoff N. Hiten</dc:creator>
            <guid>http://weblogs.sqlteam.com/geoffh/archive/2007/10/04/To-Cluster-or-Not-to-Cluster-That-SSIS-the-Question.aspx</guid>
            <pubDate>Thu, 04 Oct 2007 20:58:55 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/geoffh/archive/2007/10/04/To-Cluster-or-Not-to-Cluster-That-SSIS-the-Question.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/geoffh/comments/commentRss/60356.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/geoffh/services/trackbacks/60356.aspx</trackback:ping>
        </item>
        <item>
            <title>SQL2008 Clustering Changes</title>
            <link>http://weblogs.sqlteam.com/geoffh/archive/2007/09/26/SQL2008-Clustering-Changes.aspx</link>
            <description>&lt;p&gt;Last week I stopped by the SQL Lounge at the PASS summit in Denver.  I met a Microsoft employee named Max Verun, whose official title is Program Manager - Manageability and Servicing Platform.  Translated into ordinary geek-speak, he is in charge of Clustering and Cluster Installation.  This was a golden opportunity for me.  I spent the next hour or so listening to Max and talking with him about where SQL wants to go with clustering.  Since none of that conversation is under NDA, I thought I would share some of the highlights.&lt;/p&gt;
&lt;p&gt;Clustering will remain a High Availability failover technology.  While I suspect something like what the other guys call "clustering" is on Microsoft's radar,  I doubt very much it will be called clustering when it finally surfaces.   This isn't any inside knowledge, it is speculation that the dev team is aware of the competition and is not stupid.  &lt;/p&gt;
&lt;p&gt;Clustering will have some name changes.  The "Virtual Server" nomenclature will go away.  It is too confusing, especially now that Microsoft has gotten serious about platform Virtualization. So we will just be talking about Clustered SQL Instances in the future.  I hope this change is more successful than trying to forget the "Active/Passive..." terminology.&lt;/p&gt;
&lt;p&gt;The actual guts of clustering will remain largely unchanged.  The failover detection and timeouts work well in most cases so that stays the same.  There may be some technical changes to the SQL Cluster  Resource DLL to fix some minor issues, but the actual workings of the SQL Clustering won't change.&lt;/p&gt;
&lt;p&gt;The big changes in clustering come on the setup side.  The most important change is the division of the current installer into two pieces.  These two parts are are Setup and Configuration.  SQL Cluster install will mirror Windows Cluster Install.  With WIndows, you install the base bits including the clustering parts, then configure a cluster.  SQL will adopt the same approach.  The config tool creates a single-node clustered SQL instance.  You then add new nodes to the clustered instance.  This is a lot like WIndows Clustering, except that you can't do the SQL clustered install until the WIndows Cluster is built.  The config tool will build an INI file so you can clone the installation for the second and ssubsequent nodes.&lt;/p&gt;
&lt;p&gt;The ultimate goal here is to be able to sysprep cluster nodes and ship them pre-configured from a system builder.  That feature may or may not make it into SQL 2008 due to several other dependencies, but we will get some foundation pieces that should make it easier to install a cluster and ultimately lead up to that possibility&lt;/p&gt;
&lt;p&gt;One interesting side effect of splitting the installation functions is eliminating the current dependency on pre-qualifying hardware at the vendor level. Now, the SQL cluster configuration tool will determine if the hardware supports the desired configuration.  This should lead to some interesting configurations and lots opportunities for those of us who rescue people from their own cluster follies.  &lt;/p&gt;
&lt;p&gt;Microsoft is adding iSCSI support for clustering.  According to Max, their tests have been good as far as performance and stability.  My experience so far with iSCSI and SQL has not been so good.  I suspect the difference is due to Microsoft not purchasing their iSCSI equipment from Billy Bob's bargain computer hardware and pool cleaning service. Maybe they will have good enough tests in their tool, but I still don't trust iSCSI on a cluster.&lt;/p&gt;
&lt;p&gt;One feature Max seemed very proud of is support for up to 64 nodes in a cluster.  I guess 8 nodes isn't confusing enough.&lt;/p&gt;
&lt;p&gt;I don't have any time frames for when we will be seeing these changes, whether it is in CTPs or even in the SQL 2008 release.  I do know this is the direction the SQL Clustering team is thinking and working, but until the next release ships, nothing is locked in.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/geoffh/aggbug/60343.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Geoff N. Hiten</dc:creator>
            <guid>http://weblogs.sqlteam.com/geoffh/archive/2007/09/26/SQL2008-Clustering-Changes.aspx</guid>
            <pubDate>Wed, 26 Sep 2007 14:25:25 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/geoffh/archive/2007/09/26/SQL2008-Clustering-Changes.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/geoffh/comments/commentRss/60343.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/geoffh/services/trackbacks/60343.aspx</trackback:ping>
        </item>
    </channel>
</rss>