<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: A More Effective Selective Index Rebuild/Reorganize Strategy</title>
	<atom:link href="http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/</link>
	<description>ramblings, discoveries, tutorials on sql server and other database stuff</description>
	<lastBuildDate>Wed, 25 Jan 2012 06:55:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Alonso Fernandez</title>
		<link>http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/comment-page-1/#comment-5799</link>
		<dc:creator>Alonso Fernandez</dc:creator>
		<pubDate>Wed, 16 Mar 2011 01:04:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/#comment-5799</guid>
		<description>Hi the error 
&quot;Gives an error when you try and run the script:
Msg 102, Level 15, State 1, Line 58
Incorrect syntax near ‘(’.&quot;
is because you have a SQL 2005 with DB in compatibility 80 you can fix this error just declar 1 more variable @DB_ID smallint and set @DB_ID=DB_ID()
 DECLARE @DB_ID			smallint
 DECLARE @table_var      TABLE(  
                             objectid     int,  
                             indexid      int,  
                             partitionnum int,  
                             frag         float,
                             page_count   int  
                             )  
                             
-- Conditionally select tables and indexes from the 
-- sys.dm_db_index_physical_stats function and   
-- convert object and index IDs to names.  
set @DB_ID = DB_ID()
INSERT INTO  @table_var  
SELECT  [object_id]  AS objectid,  
        [index_id]   AS indexid,  
        [partition_number] AS partitionnum, 
        [avg_fragmentation_in_percent] AS frag,  
        [page_count]  AS page_count  
        FROM sys.dm_db_index_physical_stats (@DB_ID,NULL, NULL , NULL, &#039;LIMITED&#039;)  
        WHERE [avg_fragmentation_in_percent] &gt; @reorg_frag_thresh 
        AND  page_count &gt; @page_count_thresh  
        AND index_id &gt; 0</description>
		<content:encoded><![CDATA[<p>Hi the error<br />
&#8220;Gives an error when you try and run the script:<br />
Msg 102, Level 15, State 1, Line 58<br />
Incorrect syntax near ‘(’.&#8221;<br />
is because you have a SQL 2005 with DB in compatibility 80 you can fix this error just declar 1 more variable @DB_ID smallint and set @DB_ID=DB_ID()<br />
 DECLARE @DB_ID			smallint<br />
 DECLARE @table_var      TABLE(<br />
                             objectid     int,<br />
                             indexid      int,<br />
                             partitionnum int,<br />
                             frag         float,<br />
                             page_count   int<br />
                             )  </p>
<p>&#8211; Conditionally select tables and indexes from the<br />
&#8211; sys.dm_db_index_physical_stats function and<br />
&#8211; convert object and index IDs to names.<br />
set @DB_ID = DB_ID()<br />
INSERT INTO  @table_var<br />
SELECT  [object_id]  AS objectid,<br />
        [index_id]   AS indexid,<br />
        [partition_number] AS partitionnum,<br />
        [avg_fragmentation_in_percent] AS frag,<br />
        [page_count]  AS page_count<br />
        FROM sys.dm_db_index_physical_stats (@DB_ID,NULL, NULL , NULL, &#8216;LIMITED&#8217;)<br />
        WHERE [avg_fragmentation_in_percent] &gt; @reorg_frag_thresh<br />
        AND  page_count &gt; @page_count_thresh<br />
        AND index_id &gt; 0</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Levente Rog</title>
		<link>http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/comment-page-1/#comment-5750</link>
		<dc:creator>Levente Rog</dc:creator>
		<pubDate>Fri, 07 Jan 2011 15:28:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/#comment-5750</guid>
		<description>How do I apply this script to run on all databases on the server?</description>
		<content:encoded><![CDATA[<p>How do I apply this script to run on all databases on the server?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DBA_Tech</title>
		<link>http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/comment-page-1/#comment-5559</link>
		<dc:creator>DBA_Tech</dc:creator>
		<pubDate>Mon, 03 May 2010 20:53:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/#comment-5559</guid>
		<description>I have been using this code for quite some time. It is great. Thanks! I qwas wondering if this could be modified to scroll through all user databases on a server and perform the indexing instead of only on a prescribed database?

Thanks!</description>
		<content:encoded><![CDATA[<p>I have been using this code for quite some time. It is great. Thanks! I qwas wondering if this could be modified to scroll through all user databases on a server and perform the indexing instead of only on a prescribed database?</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arman</title>
		<link>http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/comment-page-1/#comment-3665</link>
		<dc:creator>Arman</dc:creator>
		<pubDate>Mon, 21 Dec 2009 20:17:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/#comment-3665</guid>
		<description>Belle, thank you so much for this wonderful script. For a newbie DBA like me it has proven invaluable already. The last person responsible for databases had set up maintenance jobs to reorganize AND rebuild all indexes in all databases every night; ouch! Although the server is small (in comparison to some) this maintenance plan was taking almost 3.5 hours to run. Your script reduced it to less than 20 minutes, and now is run once per week. I was wondering if you are planning on extending this script in the future? As I said I&#039;m a newbie, only started into the DBA world a few months back so am still learning. I have been reading information on LOB, Online rebuilding (Enterprise edition) and such and wondering if things like that need to be in this script or if the default variables on ALTER INDEX will cover it? Thanks again, and cheers!</description>
		<content:encoded><![CDATA[<p>Belle, thank you so much for this wonderful script. For a newbie DBA like me it has proven invaluable already. The last person responsible for databases had set up maintenance jobs to reorganize AND rebuild all indexes in all databases every night; ouch! Although the server is small (in comparison to some) this maintenance plan was taking almost 3.5 hours to run. Your script reduced it to less than 20 minutes, and now is run once per week. I was wondering if you are planning on extending this script in the future? As I said I&#8217;m a newbie, only started into the DBA world a few months back so am still learning. I have been reading information on LOB, Online rebuilding (Enterprise edition) and such and wondering if things like that need to be in this script or if the default variables on ALTER INDEX will cover it? Thanks again, and cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: belle</title>
		<link>http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/comment-page-1/#comment-2371</link>
		<dc:creator>belle</dc:creator>
		<pubDate>Fri, 09 Oct 2009 19:03:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/#comment-2371</guid>
		<description>yes it should</description>
		<content:encoded><![CDATA[<p>yes it should</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/comment-page-1/#comment-2362</link>
		<dc:creator>John</dc:creator>
		<pubDate>Thu, 08 Oct 2009 14:37:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/#comment-2362</guid>
		<description>Great script!! - fillfactor in this script means that once the rebuild index operation performed will it set all the indexes to 80% fillfactor from original?

Thanks
John</description>
		<content:encoded><![CDATA[<p>Great script!! &#8211; fillfactor in this script means that once the rebuild index operation performed will it set all the indexes to 80% fillfactor from original?</p>
<p>Thanks<br />
John</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JHopper</title>
		<link>http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/comment-page-1/#comment-1424</link>
		<dc:creator>JHopper</dc:creator>
		<pubDate>Mon, 13 Jul 2009 21:26:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/#comment-1424</guid>
		<description>Very nice script, Belle. Thanks for sharing!</description>
		<content:encoded><![CDATA[<p>Very nice script, Belle. Thanks for sharing!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tarun Rodrigues</title>
		<link>http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/comment-page-1/#comment-1302</link>
		<dc:creator>Tarun Rodrigues</dc:creator>
		<pubDate>Mon, 29 Jun 2009 23:28:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.sqlmusings.com/2009/03/15/a-more-effective-selective-index-rebuildreorganize-strategy/#comment-1302</guid>
		<description>The script concatenates PARTITION= to the reorganize/rebuild commands. Don&#039;t you think the script would throw an error in case of ALTER INDEX.. REORGANIZE; because the string is already terminated by semi-colon (;)??? And if we try to concatenate partition = to this??

Infact partition= would be concatenated after the update statistics..? It would throw an error rt.??</description>
		<content:encoded><![CDATA[<p>The script concatenates PARTITION= to the reorganize/rebuild commands. Don&#8217;t you think the script would throw an error in case of ALTER INDEX.. REORGANIZE; because the string is already terminated by semi-colon (;)??? And if we try to concatenate partition = to this??</p>
<p>Infact partition= would be concatenated after the update statistics..? It would throw an error rt.??</p>
]]></content:encoded>
	</item>
</channel>
</rss>

