<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Comparison Index Fragmentation, Index De-Fragmentation, Index Rebuild &#8211; SQL SERVER 2000 and SQL SERVER 2005</title>
	<atom:link href="http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Sat, 25 May 2013 01:31:40 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Pawan</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-272341</link>
		<dc:creator><![CDATA[Pawan]]></dc:creator>
		<pubDate>Thu, 05 Apr 2012 08:21:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-272341</guid>
		<description><![CDATA[it is in percentage]]></description>
		<content:encoded><![CDATA[<p>it is in percentage</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prashant Mohapatra</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-258930</link>
		<dc:creator><![CDATA[Prashant Mohapatra]]></dc:creator>
		<pubDate>Sat, 03 Mar 2012 13:54:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-258930</guid>
		<description><![CDATA[Hi sir

i have read one your article What is the best value for the Fill Factor? - Index, Fill Factor and Performance – Part 2
where you have explained one approx fill factor criteria. I have a query regarding cluster index. I have a table where my cluster index is on a unique column but all other columns in this table are updated through out the process.(Appx 15-20 times or more a day) Should I keep fill factor to 100 as per the unique index or should i make it somewhere in between 70-90 as data is contineously updating in this table.

Basicly I want to know what we need to do with Fill factor if my unique queue where we have the clustered index is not changing but all the rest columns are updating contioneously.]]></description>
		<content:encoded><![CDATA[<p>Hi sir</p>
<p>i have read one your article What is the best value for the Fill Factor? &#8211; Index, Fill Factor and Performance – Part 2<br />
where you have explained one approx fill factor criteria. I have a query regarding cluster index. I have a table where my cluster index is on a unique column but all other columns in this table are updated through out the process.(Appx 15-20 times or more a day) Should I keep fill factor to 100 as per the unique index or should i make it somewhere in between 70-90 as data is contineously updating in this table.</p>
<p>Basicly I want to know what we need to do with Fill factor if my unique queue where we have the clustered index is not changing but all the rest columns are updating contioneously.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Correct Value for Fillfactor &#8211; Quiz &#8211; Puzzle &#8211; 24 of 31 &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-243209</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Correct Value for Fillfactor &#8211; Quiz &#8211; Puzzle &#8211; 24 of 31 &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Wed, 25 Jan 2012 01:32:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-243209</guid>
		<description><![CDATA[[...] SQL Server Interview Questions and Answers ISBN: 1466405643 Page#151-153 SQL SERVER – What is Fill Factor and What is the Best Value for Fill Factor Fillfactor, Index and In-depth Look at Effect on Performance Rebuild Every Index of All Tables of Database – Rebuild Index with FillFactor Change Default Fill Factor For Index Comparison Index Fragmentation, Index De-Fragmentation, Index Rebuild – SQL SERVER 2000 and SQL SE... [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL Server Interview Questions and Answers ISBN: 1466405643 Page#151-153 SQL SERVER – What is Fill Factor and What is the Best Value for Fill Factor Fillfactor, Index and In-depth Look at Effect on Performance Rebuild Every Index of All Tables of Database – Rebuild Index with FillFactor Change Default Fill Factor For Index Comparison Index Fragmentation, Index De-Fragmentation, Index Rebuild – SQL SERVER 2000 and SQL SE&#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amit Kumar</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-240225</link>
		<dc:creator><![CDATA[Amit Kumar]]></dc:creator>
		<pubDate>Wed, 18 Jan 2012 13:20:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-240225</guid>
		<description><![CDATA[Hi,

I am using SQL Server 2005 and index frag is 66.67% all the time. I tired drop/create and reorganize and rebuild the indexes. but still the total fragmentation is 66.67%. How to reduce it.

Thanks!

Amit Kumar]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I am using SQL Server 2005 and index frag is 66.67% all the time. I tired drop/create and reorganize and rebuild the indexes. but still the total fragmentation is 66.67%. How to reduce it.</p>
<p>Thanks!</p>
<p>Amit Kumar</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Non-Clustered Index and Automatic Rebuild &#8211; Quiz &#8211; Puzzle &#8211; 11 of 31 &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-235695</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Non-Clustered Index and Automatic Rebuild &#8211; Quiz &#8211; Puzzle &#8211; 11 of 31 &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Thu, 12 Jan 2012 01:31:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-235695</guid>
		<description><![CDATA[[...] SQL Server Interview Questions and Answers ISBN: 1466405643 Page#67 Difference Between Index Rebuild and Index Reorganize Explained with T-SQL Script Fragmentation – Detect Fragmentation and Eliminate Fragmentation Generate Report for Index Physical Statistics – SSMS Comparison Index Fragmentation, Index De-Fragmentation, Index Rebuild – SQL SERVER 2000 and SQL SE... [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL Server Interview Questions and Answers ISBN: 1466405643 Page#67 Difference Between Index Rebuild and Index Reorganize Explained with T-SQL Script Fragmentation – Detect Fragmentation and Eliminate Fragmentation Generate Report for Index Physical Statistics – SSMS Comparison Index Fragmentation, Index De-Fragmentation, Index Rebuild – SQL SERVER 2000 and SQL SE&#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pavan</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-163608</link>
		<dc:creator><![CDATA[pavan]]></dc:creator>
		<pubDate>Tue, 30 Aug 2011 12:48:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-163608</guid>
		<description><![CDATA[Pinal ,one  question

Is there any difference between Alter Index ..Rebuild and 
DBCC DBREINDEX ?]]></description>
		<content:encoded><![CDATA[<p>Pinal ,one  question</p>
<p>Is there any difference between Alter Index ..Rebuild and<br />
DBCC DBREINDEX ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rohit</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-115291</link>
		<dc:creator><![CDATA[rohit]]></dc:creator>
		<pubDate>Mon, 31 Jan 2011 01:03:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-115291</guid>
		<description><![CDATA[Hi Pinal,

I think this is confusing please get it corrected from second line where it says rebuilding.. It conrtadicts

Heavily fragmented indexes can degrade query performance and cause your application to respond slowly. I prefer Index Rebuilding is required if Index is fragmented more than 10%. Reorganizing an index de-fragments the leaf level of clustered and non-clustered indexes on tables and views by physically reordering the leaf-level pages to match the logical order (left to right) of the leaf nodes.]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>I think this is confusing please get it corrected from second line where it says rebuilding.. It conrtadicts</p>
<p>Heavily fragmented indexes can degrade query performance and cause your application to respond slowly. I prefer Index Rebuilding is required if Index is fragmented more than 10%. Reorganizing an index de-fragments the leaf level of clustered and non-clustered indexes on tables and views by physically reordering the leaf-level pages to match the logical order (left to right) of the leaf nodes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-101632</link>
		<dc:creator><![CDATA[Sam]]></dc:creator>
		<pubDate>Tue, 23 Nov 2010 08:26:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-101632</guid>
		<description><![CDATA[Hi ,wat i do is i rebuild cluster index 1st and then noncluster indexes which is good for me.......]]></description>
		<content:encoded><![CDATA[<p>Hi ,wat i do is i rebuild cluster index 1st and then noncluster indexes which is good for me&#8230;&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kumar Setty</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-59342</link>
		<dc:creator><![CDATA[Kumar Setty]]></dc:creator>
		<pubDate>Tue, 05 Jan 2010 02:26:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-59342</guid>
		<description><![CDATA[Dear Dave, 

I have huge database around 2 tb all most of the tables are partioned. 

1. Rebuilding an index at partition level is better or the whole table. 

2. If I have to rebuild all partition 

is it better by giving partition # like below 

ALTER INDEX IX_TransactionHistory_TransactionDate
ON Production.TransactionHistory
REBUILD Partition = 5;
GO

or 

 
ALTER INDEX IX_TransactionHistory_TransactionDate
ON Production.TransactionHistory
PARTITION = ALL
 
Is the second option is same as rebuild index on the whole table or it goes one partition at a time.]]></description>
		<content:encoded><![CDATA[<p>Dear Dave, </p>
<p>I have huge database around 2 tb all most of the tables are partioned. </p>
<p>1. Rebuilding an index at partition level is better or the whole table. </p>
<p>2. If I have to rebuild all partition </p>
<p>is it better by giving partition # like below </p>
<p>ALTER INDEX IX_TransactionHistory_TransactionDate<br />
ON Production.TransactionHistory<br />
REBUILD Partition = 5;<br />
GO</p>
<p>or </p>
<p>ALTER INDEX IX_TransactionHistory_TransactionDate<br />
ON Production.TransactionHistory<br />
PARTITION = ALL</p>
<p>Is the second option is same as rebuild index on the whole table or it goes one partition at a time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: akumar</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-53421</link>
		<dc:creator><![CDATA[akumar]]></dc:creator>
		<pubDate>Thu, 02 Jul 2009 12:59:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-53421</guid>
		<description><![CDATA[Hi,

Could please provide me the archiecture of sqlserver2005.

I just want to know how it works]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Could please provide me the archiecture of sqlserver2005.</p>
<p>I just want to know how it works</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQLAuthority News - Best Articles on SQLAuthority.com Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-47225</link>
		<dc:creator><![CDATA[SQLAuthority News - Best Articles on SQLAuthority.com Journey to SQL Authority with Pinal Dave]]></dc:creator>
		<pubDate>Tue, 24 Feb 2009 12:09:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-47225</guid>
		<description><![CDATA[[...] SQL SERVER - Comparison Index Fragmentation, Index De-Fragmentation, Index Rebuild - SQL SERVER 2000... [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER &#8211; Comparison Index Fragmentation, Index De-Fragmentation, Index Rebuild &#8211; SQL SERVER 2000&#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sedgey</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-46434</link>
		<dc:creator><![CDATA[sedgey]]></dc:creator>
		<pubDate>Sat, 07 Feb 2009 20:26:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-46434</guid>
		<description><![CDATA[Nice article, just what I was looking for]]></description>
		<content:encoded><![CDATA[<p>Nice article, just what I was looking for</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: M Azim</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-45513</link>
		<dc:creator><![CDATA[M Azim]]></dc:creator>
		<pubDate>Sat, 10 Jan 2009 08:11:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-45513</guid>
		<description><![CDATA[Dear Pinal Dave,


I am facing a problem while rebuilding or reorganising a few of my DB inedexes. My Environment is SQL Server 2005 and I am using &quot;ALTER INDEX ....&quot; command.
These indexes remain &quot;Fragmented&quot;  even aftre rebuilding or reorganising  severl time.
Can you please tell me what could be the reasons?

With Regards,

M Azim]]></description>
		<content:encoded><![CDATA[<p>Dear Pinal Dave,</p>
<p>I am facing a problem while rebuilding or reorganising a few of my DB inedexes. My Environment is SQL Server 2005 and I am using &#8220;ALTER INDEX &#8230;.&#8221; command.<br />
These indexes remain &#8220;Fragmented&#8221;  even aftre rebuilding or reorganising  severl time.<br />
Can you please tell me what could be the reasons?</p>
<p>With Regards,</p>
<p>M Azim</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul DeBrino</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-44187</link>
		<dc:creator><![CDATA[Paul DeBrino]]></dc:creator>
		<pubDate>Wed, 12 Nov 2008 20:34:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-44187</guid>
		<description><![CDATA[MODERATOR: HOW ARE YOU ABLE TO POST SCRIPT AND RETAIN COLORS AND INDENTATION?

This is a the latest version of this script as of 2008-11-12: 

&lt;code&gt;

/* 
Script originally authored by Microsoft but had an error - It was retrieving data without prefixing database schema.

-Added a @ViewOnly variable that will allow you to run this script as a test only and review proposed actions. Simply change the value to 0 to execute the proposed actions.
-Also enhanced to perform either a reorg or rebuild, based on range of fragmentation value.
-Also included pages value from DBCC SHOWCONTIG for analysis, to support theory that defragging indexes have few pages is not productive.
~Paul DeBrino : infinityrd.com : Nov 2008

USEFUL INFO -- INSPECT INDEXES&#039; FILL FACTOR VALUES:
============================================
use YourDBName
select * from sys.indexes order by name

USEFUL INFO -- VIEW THE DEFAULT FILL FACTOR OF YOUR SERVER:
============================================
use YourDBname
exec sp_configure &#039;show advanced options&#039;, 1
go
reconfigure
go
exec sp_configure &#039;fill factor&#039;
go
*/

-- Specify your Database Name:
USE YourDBName

-- Declare variables:
SET NOCOUNT ON
DECLARE @tablename VARCHAR(128)
DECLARE @execstr   VARCHAR(255)
DECLARE @objectid  INT
DECLARE @indexid   INT
DECLARE @frag      decimal
DECLARE @maxreorg   decimal
DECLARE @maxrebuild decimal
DECLARE @IdxName   varchar(128)
DECLARE @pages		INT
DECLARE @maxpages	INT
DECLARE @ViewOnly  bit
DECLARE @ReorgOptions varchar(255)
DECLARE @RebuildOptions varchar(255)

-- Set to 1 to view proposed actions, set to 0 to Execute proposed actions:
SET @ViewOnly=1

-- Decide on the maximum number of pages to consider index for reorg or rebuild:
-- NOTE: Set to 0 if you wish not to consider this value for analysis.
-- Reference http://sqlblog.com/blogs/kalen_delaney/archive/2008/02/28/fragmentation-revisited.aspx
SET @maxpages = 100
-- Decide on the maximum fragmentation to allow for a reorganize:
-- AVAILABLE OPTIONS: http://technet.microsoft.com/en-us/library/ms188388(SQL.90).aspx
SET @maxreorg = 20.0
SET @ReorgOptions = &#039;LOB_COMPACTION=ON&#039;
-- Decide on the maximum fragmentation to allow for a rebuild:
SET @maxrebuild = 30.0
-- NOTE: only specifiy FILLFACTOR=x if x is a value other than 0 (otherwise do not include the fillfactor option at all):
SET @RebuildOptions = &#039;PAD_INDEX=OFF, FILLFACTOR=90, SORT_IN_TEMPDB=ON, STATISTICS_NORECOMPUTE=OFF, ALLOW_ROW_LOCKS=ON, ALLOW_PAGE_LOCKS=ON&#039;

-- Declare a cursor to process list of tables:
DECLARE tables CURSOR FOR
   SELECT CAST(TABLE_SCHEMA AS VARCHAR(100))
	+&#039;.&#039;+CAST(TABLE_NAME AS VARCHAR(100))
           AS Table_Name
   FROM INFORMATION_SCHEMA.TABLES
   WHERE TABLE_TYPE = &#039;BASE TABLE&#039;

-- Create the temporary table:
if exists (select name from tempdb.dbo.sysobjects where name like &#039;#fraglist%&#039;)
	drop table #fraglist

CREATE TABLE #fraglist (
   ObjectName CHAR(255),
   ObjectId INT,
   IndexName CHAR(255),
   IndexId INT,
   Lvl INT,
   CountPages INT,
   CountRows INT,
   MinRecSize INT,
   MaxRecSize INT,
   AvgRecSize INT,
   ForRecCount INT,
   Extents INT,
   ExtentSwitches INT,
   AvgFreeBytes INT,
   AvgPageDensity INT,
   ScanDensity decimal,
   BestCount INT,
   ActualCount INT,
   LogicalFrag decimal,
   ExtentFrag decimal)

-- Open the cursor:
OPEN tables

-- Loop through all the tables in the database:
FETCH NEXT
   FROM tables
   INTO @tablename

WHILE @@FETCH_STATUS = 0
BEGIN
-- Perform showcontig on all indexes for the current table:
   INSERT INTO #fraglist
   EXEC (&#039;DBCC SHOWCONTIG (&#039;&#039;&#039; + @tablename + &#039;&#039;&#039;)
      WITH FAST, TABLERESULTS, ALL_INDEXES, NO_INFOMSGS&#039;)
   FETCH NEXT
      FROM tables
      INTO @tablename
END

-- Close and deallocate the cursor:
CLOSE tables
DEALLOCATE tables

-- Declare the cursor for the list of indexes to be defragged:
DECLARE indexes CURSOR FOR
   SELECT ObjectName, ObjectId, IndexId, LogicalFrag, IndexName, CountPages 
   FROM #fraglist
   --WHERE ((LogicalFrag &gt;= @maxreorg) OR (LogicalFrag &gt;= @maxrebuild))
   WHERE INDEXPROPERTY (ObjectId, IndexName, &#039;IndexDepth&#039;) &gt; 0

-- Open the cursor:
OPEN indexes

-- Loop through the indexes:
FETCH NEXT
   FROM indexes
   INTO @tablename, @objectid, @indexid, @frag, @IdxName, @pages

WHILE @@FETCH_STATUS = 0
BEGIN
	-- Determine if index page count surpasses the defined threshold for needed maintenance:
	IF (@pages &gt;= @maxpages)
	BEGIN
		-- Determine if fragmentation surpasses the defined threshold for rebuilding:
		IF (@frag &gt;= @maxrebuild)
		BEGIN
			IF (@ViewOnly=1)
			BEGIN
				PRINT &#039;WOULD be executing ALTER INDEX &#039; + RTRIM(@IdxName) + &#039; ON &#039; + RTRIM(@tablename) + &#039; REBUILD WITH ( &#039; + @RebuildOptions + &#039; ) -- Fragmentation currently &#039; + RTRIM(CONVERT(VARCHAR(15),@frag)) + &#039;% and Pages were &#039; + RTRIM(CONVERT(VARCHAR(15),@pages))
			END
			ELSE
			BEGIN
				PRINT &#039;Now executing ALTER INDEX &#039; + RTRIM(@IdxName) + &#039; ON &#039; + RTRIM(@tablename) + &#039; REBUILD WITH ( &#039; + @RebuildOptions + &#039; ) -- Fragmentation currently &#039; + RTRIM(CONVERT(VARCHAR(15),@frag)) + &#039;% and Pages were &#039; + RTRIM(CONVERT(VARCHAR(15),@pages))
				SELECT @execstr = &#039;ALTER INDEX &#039; + RTRIM(@IdxName) + &#039; ON &#039; + RTRIM(@tablename) + &#039; REBUILD WITH ( &#039; + @RebuildOptions + &#039; )&#039;
				EXEC (@execstr)
			END
		END
		-- Determine if fragmentation surpasses the defined threshold for reorganizing:
		ELSE IF (@frag &gt;= @maxreorg)
		BEGIN
			IF (@ViewOnly=1)
			BEGIN
				PRINT &#039;WOULD be executing ALTER INDEX &#039; + RTRIM(@IdxName) + &#039; ON &#039; + RTRIM(@tablename) + &#039; REORGANIZE WITH ( &#039; + @ReorgOptions + &#039; ) -- Fragmentation currently &#039; + RTRIM(CONVERT(VARCHAR(15),@frag)) + &#039;% and Pages were &#039; + RTRIM(CONVERT(VARCHAR(15),@pages))
			END
			ELSE
			BEGIN
				PRINT &#039;Now executing ALTER INDEX &#039; + RTRIM(@IdxName) + &#039; ON &#039; + RTRIM(@tablename) + &#039; REORGANIZE WITH ( &#039; + @ReorgOptions + &#039; ) -- Fragmentation currently &#039; + RTRIM(CONVERT(VARCHAR(15),@frag)) + &#039;% and Pages were &#039; + RTRIM(CONVERT(VARCHAR(15),@pages))
				SELECT @execstr = &#039;ALTER INDEX &#039; + RTRIM(@IdxName) + &#039; ON &#039; + RTRIM(@tablename) + &#039; REORGANIZE WITH ( &#039; + @ReorgOptions + &#039; )&#039;
				EXEC (@execstr)
			END
		END
		ELSE
		BEGIN
			PRINT &#039;--BYPASSING INDEX &#039; + RTRIM(@IdxName) + &#039; ON &#039; + RTRIM(@tablename) + &#039; since fragmentation is currently &#039; + RTRIM(CONVERT(VARCHAR(15),@frag)) + &#039;% which is less than the Reorg and Rebuild thresholds.&#039;
		END
	END
	ELSE
	BEGIN
		PRINT &#039;--BYPASSING INDEX &#039; + RTRIM(@IdxName) + &#039; ON &#039; + RTRIM(@tablename) + &#039; since Page Count was &#039; + RTRIM(CONVERT(VARCHAR(15),@pages)) + &#039; which is less than threshold. Fragmentation is currently &#039; + RTRIM(CONVERT(VARCHAR(15),@frag)) + &#039;%&#039;
	END

   FETCH NEXT
      FROM indexes
      INTO @tablename, @objectid, @indexid, @frag, @IdxName, @pages
END

-- Close and deallocate the cursor:
CLOSE indexes
DEALLOCATE indexes

-- Delete the temporary table:
DROP TABLE #fraglist
GO



&lt;/code&gt;]]></description>
		<content:encoded><![CDATA[<p>MODERATOR: HOW ARE YOU ABLE TO POST SCRIPT AND RETAIN COLORS AND INDENTATION?</p>
<p>This is a the latest version of this script as of 2008-11-12: </p>
<p><code></p>
<p>/*<br />
Script originally authored by Microsoft but had an error - It was retrieving data without prefixing database schema.</p>
<p>-Added a @ViewOnly variable that will allow you to run this script as a test only and review proposed actions. Simply change the value to 0 to execute the proposed actions.<br />
-Also enhanced to perform either a reorg or rebuild, based on range of fragmentation value.<br />
-Also included pages value from DBCC SHOWCONTIG for analysis, to support theory that defragging indexes have few pages is not productive.<br />
~Paul DeBrino : infinityrd.com : Nov 2008</p>
<p>USEFUL INFO -- INSPECT INDEXES' FILL FACTOR VALUES:<br />
============================================<br />
use YourDBName<br />
select * from sys.indexes order by name</p>
<p>USEFUL INFO -- VIEW THE DEFAULT FILL FACTOR OF YOUR SERVER:<br />
============================================<br />
use YourDBname<br />
exec sp_configure 'show advanced options', 1<br />
go<br />
reconfigure<br />
go<br />
exec sp_configure 'fill factor'<br />
go<br />
*/</p>
<p>-- Specify your Database Name:<br />
USE YourDBName</p>
<p>-- Declare variables:<br />
SET NOCOUNT ON<br />
DECLARE @tablename VARCHAR(128)<br />
DECLARE @execstr   VARCHAR(255)<br />
DECLARE @objectid  INT<br />
DECLARE @indexid   INT<br />
DECLARE @frag      decimal<br />
DECLARE @maxreorg   decimal<br />
DECLARE @maxrebuild decimal<br />
DECLARE @IdxName   varchar(128)<br />
DECLARE @pages		INT<br />
DECLARE @maxpages	INT<br />
DECLARE @ViewOnly  bit<br />
DECLARE @ReorgOptions varchar(255)<br />
DECLARE @RebuildOptions varchar(255)</p>
<p>-- Set to 1 to view proposed actions, set to 0 to Execute proposed actions:<br />
SET @ViewOnly=1</p>
<p>-- Decide on the maximum number of pages to consider index for reorg or rebuild:<br />
-- NOTE: Set to 0 if you wish not to consider this value for analysis.<br />
-- Reference <a href="http://sqlblog.com/blogs/kalen_delaney/archive/2008/02/28/fragmentation-revisited.aspx" rel="nofollow">http://sqlblog.com/blogs/kalen_delaney/archive/2008/02/28/fragmentation-revisited.aspx</a><br />
SET @maxpages = 100<br />
-- Decide on the maximum fragmentation to allow for a reorganize:<br />
-- AVAILABLE OPTIONS: <a href="http://technet.microsoft.com/en-us/library/ms188388(SQL.90)" rel="nofollow">http://technet.microsoft.com/en-us/library/ms188388(SQL.90)</a>.aspx<br />
SET @maxreorg = 20.0<br />
SET @ReorgOptions = 'LOB_COMPACTION=ON'<br />
-- Decide on the maximum fragmentation to allow for a rebuild:<br />
SET @maxrebuild = 30.0<br />
-- NOTE: only specifiy FILLFACTOR=x if x is a value other than 0 (otherwise do not include the fillfactor option at all):<br />
SET @RebuildOptions = 'PAD_INDEX=OFF, FILLFACTOR=90, SORT_IN_TEMPDB=ON, STATISTICS_NORECOMPUTE=OFF, ALLOW_ROW_LOCKS=ON, ALLOW_PAGE_LOCKS=ON'</p>
<p>-- Declare a cursor to process list of tables:<br />
DECLARE tables CURSOR FOR<br />
   SELECT CAST(TABLE_SCHEMA AS VARCHAR(100))<br />
	+'.'+CAST(TABLE_NAME AS VARCHAR(100))<br />
           AS Table_Name<br />
   FROM INFORMATION_SCHEMA.TABLES<br />
   WHERE TABLE_TYPE = 'BASE TABLE'</p>
<p>-- Create the temporary table:<br />
if exists (select name from tempdb.dbo.sysobjects where name like '#fraglist%')<br />
	drop table #fraglist</p>
<p>CREATE TABLE #fraglist (<br />
   ObjectName CHAR(255),<br />
   ObjectId INT,<br />
   IndexName CHAR(255),<br />
   IndexId INT,<br />
   Lvl INT,<br />
   CountPages INT,<br />
   CountRows INT,<br />
   MinRecSize INT,<br />
   MaxRecSize INT,<br />
   AvgRecSize INT,<br />
   ForRecCount INT,<br />
   Extents INT,<br />
   ExtentSwitches INT,<br />
   AvgFreeBytes INT,<br />
   AvgPageDensity INT,<br />
   ScanDensity decimal,<br />
   BestCount INT,<br />
   ActualCount INT,<br />
   LogicalFrag decimal,<br />
   ExtentFrag decimal)</p>
<p>-- Open the cursor:<br />
OPEN tables</p>
<p>-- Loop through all the tables in the database:<br />
FETCH NEXT<br />
   FROM tables<br />
   INTO @tablename</p>
<p>WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
-- Perform showcontig on all indexes for the current table:<br />
   INSERT INTO #fraglist<br />
   EXEC ('DBCC SHOWCONTIG (''' + @tablename + ''')<br />
      WITH FAST, TABLERESULTS, ALL_INDEXES, NO_INFOMSGS')<br />
   FETCH NEXT<br />
      FROM tables<br />
      INTO @tablename<br />
END</p>
<p>-- Close and deallocate the cursor:<br />
CLOSE tables<br />
DEALLOCATE tables</p>
<p>-- Declare the cursor for the list of indexes to be defragged:<br />
DECLARE indexes CURSOR FOR<br />
   SELECT ObjectName, ObjectId, IndexId, LogicalFrag, IndexName, CountPages<br />
   FROM #fraglist<br />
   --WHERE ((LogicalFrag &gt;= @maxreorg) OR (LogicalFrag &gt;= @maxrebuild))<br />
   WHERE INDEXPROPERTY (ObjectId, IndexName, 'IndexDepth') &gt; 0</p>
<p>-- Open the cursor:<br />
OPEN indexes</p>
<p>-- Loop through the indexes:<br />
FETCH NEXT<br />
   FROM indexes<br />
   INTO @tablename, @objectid, @indexid, @frag, @IdxName, @pages</p>
<p>WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
	-- Determine if index page count surpasses the defined threshold for needed maintenance:<br />
	IF (@pages &gt;= @maxpages)<br />
	BEGIN<br />
		-- Determine if fragmentation surpasses the defined threshold for rebuilding:<br />
		IF (@frag &gt;= @maxrebuild)<br />
		BEGIN<br />
			IF (@ViewOnly=1)<br />
			BEGIN<br />
				PRINT 'WOULD be executing ALTER INDEX ' + RTRIM(@IdxName) + ' ON ' + RTRIM(@tablename) + ' REBUILD WITH ( ' + @RebuildOptions + ' ) -- Fragmentation currently ' + RTRIM(CONVERT(VARCHAR(15),@frag)) + '% and Pages were ' + RTRIM(CONVERT(VARCHAR(15),@pages))<br />
			END<br />
			ELSE<br />
			BEGIN<br />
				PRINT 'Now executing ALTER INDEX ' + RTRIM(@IdxName) + ' ON ' + RTRIM(@tablename) + ' REBUILD WITH ( ' + @RebuildOptions + ' ) -- Fragmentation currently ' + RTRIM(CONVERT(VARCHAR(15),@frag)) + '% and Pages were ' + RTRIM(CONVERT(VARCHAR(15),@pages))<br />
				SELECT @execstr = 'ALTER INDEX ' + RTRIM(@IdxName) + ' ON ' + RTRIM(@tablename) + ' REBUILD WITH ( ' + @RebuildOptions + ' )'<br />
				EXEC (@execstr)<br />
			END<br />
		END<br />
		-- Determine if fragmentation surpasses the defined threshold for reorganizing:<br />
		ELSE IF (@frag &gt;= @maxreorg)<br />
		BEGIN<br />
			IF (@ViewOnly=1)<br />
			BEGIN<br />
				PRINT 'WOULD be executing ALTER INDEX ' + RTRIM(@IdxName) + ' ON ' + RTRIM(@tablename) + ' REORGANIZE WITH ( ' + @ReorgOptions + ' ) -- Fragmentation currently ' + RTRIM(CONVERT(VARCHAR(15),@frag)) + '% and Pages were ' + RTRIM(CONVERT(VARCHAR(15),@pages))<br />
			END<br />
			ELSE<br />
			BEGIN<br />
				PRINT 'Now executing ALTER INDEX ' + RTRIM(@IdxName) + ' ON ' + RTRIM(@tablename) + ' REORGANIZE WITH ( ' + @ReorgOptions + ' ) -- Fragmentation currently ' + RTRIM(CONVERT(VARCHAR(15),@frag)) + '% and Pages were ' + RTRIM(CONVERT(VARCHAR(15),@pages))<br />
				SELECT @execstr = 'ALTER INDEX ' + RTRIM(@IdxName) + ' ON ' + RTRIM(@tablename) + ' REORGANIZE WITH ( ' + @ReorgOptions + ' )'<br />
				EXEC (@execstr)<br />
			END<br />
		END<br />
		ELSE<br />
		BEGIN<br />
			PRINT '--BYPASSING INDEX ' + RTRIM(@IdxName) + ' ON ' + RTRIM(@tablename) + ' since fragmentation is currently ' + RTRIM(CONVERT(VARCHAR(15),@frag)) + '% which is less than the Reorg and Rebuild thresholds.'<br />
		END<br />
	END<br />
	ELSE<br />
	BEGIN<br />
		PRINT '--BYPASSING INDEX ' + RTRIM(@IdxName) + ' ON ' + RTRIM(@tablename) + ' since Page Count was ' + RTRIM(CONVERT(VARCHAR(15),@pages)) + ' which is less than threshold. Fragmentation is currently ' + RTRIM(CONVERT(VARCHAR(15),@frag)) + '%'<br />
	END</p>
<p>   FETCH NEXT<br />
      FROM indexes<br />
      INTO @tablename, @objectid, @indexid, @frag, @IdxName, @pages<br />
END</p>
<p>-- Close and deallocate the cursor:<br />
CLOSE indexes<br />
DEALLOCATE indexes</p>
<p>-- Delete the temporary table:<br />
DROP TABLE #fraglist<br />
GO</p>
<p></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: WCM</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-44186</link>
		<dc:creator><![CDATA[WCM]]></dc:creator>
		<pubDate>Wed, 12 Nov 2008 19:55:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-44186</guid>
		<description><![CDATA[Pinal Dave,

What are your thoughts on this post from Kalen Delaney?

http://sqlblog.com/blogs/kalen_delaney/archive/2008/02/28/fragmentation-revisited.aspx

Excerpts:
&quot;Fragmentation is really only an issue if there are LOTS of pages. I usually say that if there are less than 100 pages, you should never worry about fragmentation. However, this this whitepaper suggests that a better cutoff would actually be 1000 pages: (link)&quot;  See orig post for actual link.

&quot;REBUILD doesn&#039;t seem to make a difference in the avg_fragmentation_in_percent value is when there are too few pages in the table.&quot;

Thanks,
WCM]]></description>
		<content:encoded><![CDATA[<p>Pinal Dave,</p>
<p>What are your thoughts on this post from Kalen Delaney?</p>
<p><a href="http://sqlblog.com/blogs/kalen_delaney/archive/2008/02/28/fragmentation-revisited.aspx" rel="nofollow">http://sqlblog.com/blogs/kalen_delaney/archive/2008/02/28/fragmentation-revisited.aspx</a></p>
<p>Excerpts:<br />
&#8220;Fragmentation is really only an issue if there are LOTS of pages. I usually say that if there are less than 100 pages, you should never worry about fragmentation. However, this this whitepaper suggests that a better cutoff would actually be 1000 pages: (link)&#8221;  See orig post for actual link.</p>
<p>&#8220;REBUILD doesn&#8217;t seem to make a difference in the avg_fragmentation_in_percent value is when there are too few pages in the table.&#8221;</p>
<p>Thanks,<br />
WCM</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Basharit</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-42353</link>
		<dc:creator><![CDATA[Basharit]]></dc:creator>
		<pubDate>Wed, 03 Sep 2008 08:37:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-42353</guid>
		<description><![CDATA[Dear Pinal Dave

i heared alot abt u. impressive....
i am working in dubai. we are havinf problem related to Database Performance. Few days before, we upgraded the sql server. we moved our database from sql server  2000 to sql server 2005 by restoring the backup of SQL server 2000 on SQL Server 2005. we are having a web site which is using this Database. The database was working normally on sql server 200 but after we moved, its dead slow...i mean the over all performance of DB is very slow..we reindex the Database again in SQL Server 2005 but no use...its still same...

Just wanna know, is there any setting in SQL Server 2005 after restoring database from SQL Server 2000???
i mean can u help me which step i am missing ???

hope to have your reply soon

Regards

BASHARIT]]></description>
		<content:encoded><![CDATA[<p>Dear Pinal Dave</p>
<p>i heared alot abt u. impressive&#8230;.<br />
i am working in dubai. we are havinf problem related to Database Performance. Few days before, we upgraded the sql server. we moved our database from sql server  2000 to sql server 2005 by restoring the backup of SQL server 2000 on SQL Server 2005. we are having a web site which is using this Database. The database was working normally on sql server 200 but after we moved, its dead slow&#8230;i mean the over all performance of DB is very slow..we reindex the Database again in SQL Server 2005 but no use&#8230;its still same&#8230;</p>
<p>Just wanna know, is there any setting in SQL Server 2005 after restoring database from SQL Server 2000???<br />
i mean can u help me which step i am missing ???</p>
<p>hope to have your reply soon</p>
<p>Regards</p>
<p>BASHARIT</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael's personal blog</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-40399</link>
		<dc:creator><![CDATA[Michael's personal blog]]></dc:creator>
		<pubDate>Thu, 17 Jul 2008 22:21:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-40399</guid>
		<description><![CDATA[&lt;strong&gt;How to find fragmented indexs in MSSQL ...&lt;/strong&gt;

to find fragmented indexes

SQL SERVER 2000:
DBCC SHOWCONTIG was used to find index fragmentation. In SQL SERVER 2005 it is deprecated and replaced by query to sys.DM_DB_INDEX_PHYSICAL_STATS.

SQL SERVER 2005:
SELECT query to sys.DM_DB_INDEX_PHYSICAL_S...]]></description>
		<content:encoded><![CDATA[<p><strong>How to find fragmented indexs in MSSQL &#8230;</strong></p>
<p>to find fragmented indexes</p>
<p>SQL SERVER 2000:<br />
DBCC SHOWCONTIG was used to find index fragmentation. In SQL SERVER 2005 it is deprecated and replaced by query to sys.DM_DB_INDEX_PHYSICAL_STATS.</p>
<p>SQL SERVER 2005:<br />
SELECT query to sys.DM_DB_INDEX_PHYSICAL_S&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arin</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-39336</link>
		<dc:creator><![CDATA[Arin]]></dc:creator>
		<pubDate>Wed, 18 Jun 2008 19:29:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-39336</guid>
		<description><![CDATA[Dave,

After reading your post I wanted to point something out.  You said:

&quot;I have been asked following two questions many times:
1) What is difference between FILLFACTOR = 0 AND FILLFACTOR = 100?
They are SAME.&quot;

I cannot speak on behalf on SQL 2005 but with SQL 2k this is not an entirely a true statement as there is a difference between the two.

FILLFACTOR = 100 is 100% fill rate and is generally a bad idea.

FILLFACTOR = 0 is a wildcard for whatever the existing fill factor on the index was set to previously.

If the index previously had a FILLFACTOR of 100 then this statement would be true as the fill rate would be 100%.  

However if the index had a FILLFACTOR of 90 and a FILLFACTOR = 0 was used, the fill rate of 90% would be retained.

I use a FILLFACTOR of 0 almost exclusively when reindexing a database, as FILLFACTOR&#039;s on index should be individually tuned based on types of activity in that particular table.  I would not want to change those values when doing a bulk reindex of a database.]]></description>
		<content:encoded><![CDATA[<p>Dave,</p>
<p>After reading your post I wanted to point something out.  You said:</p>
<p>&#8220;I have been asked following two questions many times:<br />
1) What is difference between FILLFACTOR = 0 AND FILLFACTOR = 100?<br />
They are SAME.&#8221;</p>
<p>I cannot speak on behalf on SQL 2005 but with SQL 2k this is not an entirely a true statement as there is a difference between the two.</p>
<p>FILLFACTOR = 100 is 100% fill rate and is generally a bad idea.</p>
<p>FILLFACTOR = 0 is a wildcard for whatever the existing fill factor on the index was set to previously.</p>
<p>If the index previously had a FILLFACTOR of 100 then this statement would be true as the fill rate would be 100%.  </p>
<p>However if the index had a FILLFACTOR of 90 and a FILLFACTOR = 0 was used, the fill rate of 90% would be retained.</p>
<p>I use a FILLFACTOR of 0 almost exclusively when reindexing a database, as FILLFACTOR&#8217;s on index should be individually tuned based on types of activity in that particular table.  I would not want to change those values when doing a bulk reindex of a database.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL Junkie</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-35847</link>
		<dc:creator><![CDATA[SQL Junkie]]></dc:creator>
		<pubDate>Mon, 28 Apr 2008 20:00:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-35847</guid>
		<description><![CDATA[I&#039;m just wondering and frustrated about what is wrong with the code below. It executes perfectly on many DBs we have but fails on some throwing the error &quot;Incorrect synatx near the keyword &#039;with&#039;.

DECLARE @Database VARCHAR(100)   
DECLARE @Table VARCHAR(100)  
DECLARE @cmd NVARCHAR(300)  
DECLARE @fillfactor INT 

SET @fillfactor = 70
SET @Database = &#039;TestOnly&#039;

   SET @cmd = &#039;DECLARE TableCursor CURSOR FOR SELECT table_catalog + &#039;&#039;.&#039;&#039; + table_schema + &#039;&#039;.&#039;&#039; + table_name as tableName   
                    FROM &#039; + @Database + &#039;.INFORMATION_SCHEMA.TABLES WHERE table_type = &#039;&#039;BASE TABLE&#039;&#039;&#039;   

 
   EXEC (@cmd)  
   OPEN TableCursor   

   FETCH NEXT FROM TableCursor INTO @Table   
   WHILE @@FETCH_STATUS = 0   
   BEGIN   

 
         
       
       SET @cmd = &#039;ALTER INDEX ALL ON &#039; + @Table + &#039; REBUILD WITH (FILLFACTOR = &#039; + CONVERT(VARCHAR(3),@fillfactor) + &#039;)&#039;  
       EXEC (@cmd)  

       FETCH NEXT FROM TableCursor INTO @Table   
   END   

   CLOSE TableCursor   
   DEALLOCATE TableCursor]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m just wondering and frustrated about what is wrong with the code below. It executes perfectly on many DBs we have but fails on some throwing the error &#8220;Incorrect synatx near the keyword &#8216;with&#8217;.</p>
<p>DECLARE @Database VARCHAR(100)<br />
DECLARE @Table VARCHAR(100)<br />
DECLARE @cmd NVARCHAR(300)<br />
DECLARE @fillfactor INT </p>
<p>SET @fillfactor = 70<br />
SET @Database = &#8216;TestOnly&#8217;</p>
<p>   SET @cmd = &#8216;DECLARE TableCursor CURSOR FOR SELECT table_catalog + &#8221;.&#8221; + table_schema + &#8221;.&#8221; + table_name as tableName<br />
                    FROM &#8216; + @Database + &#8216;.INFORMATION_SCHEMA.TABLES WHERE table_type = &#8221;BASE TABLE&#8221;&#8217;   </p>
<p>   EXEC (@cmd)<br />
   OPEN TableCursor   </p>
<p>   FETCH NEXT FROM TableCursor INTO @Table<br />
   WHILE @@FETCH_STATUS = 0<br />
   BEGIN   </p>
<p>       SET @cmd = &#8216;ALTER INDEX ALL ON &#8216; + @Table + &#8216; REBUILD WITH (FILLFACTOR = &#8216; + CONVERT(VARCHAR(3),@fillfactor) + &#8216;)&#8217;<br />
       EXEC (@cmd)  </p>
<p>       FETCH NEXT FROM TableCursor INTO @Table<br />
   END   </p>
<p>   CLOSE TableCursor<br />
   DEALLOCATE TableCursor</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: amit saxena</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-35105</link>
		<dc:creator><![CDATA[amit saxena]]></dc:creator>
		<pubDate>Tue, 15 Apr 2008 17:37:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-35105</guid>
		<description><![CDATA[Hi Pinal,
             i am working on a banking project for a financial bank.it deals with end of day and start of day...i have created some indexes in it. i m getting  some error while end of day of any branch.

Error messages:
The replication agent has not logged a progress message in 10 minutes. This might indicate an unresponsive agent or high system activity. Verify that records are being replicated to the destination and that connections to the Subscriber, Publisher, and Distributor are still active. shud i try to defragment it, how can i defragment it.plz give me a long term solution bcoz branches are going to increase like anything... do u have any contact no. its urgent]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,<br />
             i am working on a banking project for a financial bank.it deals with end of day and start of day&#8230;i have created some indexes in it. i m getting  some error while end of day of any branch.</p>
<p>Error messages:<br />
The replication agent has not logged a progress message in 10 minutes. This might indicate an unresponsive agent or high system activity. Verify that records are being replicated to the destination and that connections to the Subscriber, Publisher, and Distributor are still active. shud i try to defragment it, how can i defragment it.plz give me a long term solution bcoz branches are going to increase like anything&#8230; do u have any contact no. its urgent</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-35001</link>
		<dc:creator><![CDATA[Paul]]></dc:creator>
		<pubDate>Fri, 11 Apr 2008 20:50:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-35001</guid>
		<description><![CDATA[Pinal, stupid question:

The value returned for avg_fragmentation_in_percent from 
sys.dm_db_index_physical_stats is Percent or .%

i.e. if .01 is returned is that .01% or 10% ?

Thanks,
Paul]]></description>
		<content:encoded><![CDATA[<p>Pinal, stupid question:</p>
<p>The value returned for avg_fragmentation_in_percent from<br />
sys.dm_db_index_physical_stats is Percent or .%</p>
<p>i.e. if .01 is returned is that .01% or 10% ?</p>
<p>Thanks,<br />
Paul</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-34973</link>
		<dc:creator><![CDATA[Imran]]></dc:creator>
		<pubDate>Thu, 10 Apr 2008 17:40:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-34973</guid>
		<description><![CDATA[@ TODD

Well it worked for me ...

I created a table with a primary key, which create a clustered index by default and then I checked the fragmentation level using the command given by Dave, I saw the level was 0 (Zero)

Then I inserted 12000 rows in the table, then I saw the index fragmentation level was 20 % , and then I executed the second query, 

Instantly my index fragmentation level became 0 %. 

Worked for me ... !]]></description>
		<content:encoded><![CDATA[<p>@ TODD</p>
<p>Well it worked for me &#8230;</p>
<p>I created a table with a primary key, which create a clustered index by default and then I checked the fragmentation level using the command given by Dave, I saw the level was 0 (Zero)</p>
<p>Then I inserted 12000 rows in the table, then I saw the index fragmentation level was 20 % , and then I executed the second query, </p>
<p>Instantly my index fragmentation level became 0 %. </p>
<p>Worked for me &#8230; !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Garnet</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-34955</link>
		<dc:creator><![CDATA[Garnet]]></dc:creator>
		<pubDate>Thu, 10 Apr 2008 01:11:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-34955</guid>
		<description><![CDATA[You mention index fragmentation... What about table fragmentation?  If the index is rebuild, does the fragmentation of the actual data no longer matter?]]></description>
		<content:encoded><![CDATA[<p>You mention index fragmentation&#8230; What about table fragmentation?  If the index is rebuild, does the fragmentation of the actual data no longer matter?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Foote</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-33378</link>
		<dc:creator><![CDATA[Aaron Foote]]></dc:creator>
		<pubDate>Thu, 31 Jan 2008 05:11:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-33378</guid>
		<description><![CDATA[I&#039;m a fan of your work.

Whats the difference between rebuild and reorganize?  Do they just run at different speeds or is there some other difference between them.

Cheers,
Aaron]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m a fan of your work.</p>
<p>Whats the difference between rebuild and reorganize?  Do they just run at different speeds or is there some other difference between them.</p>
<p>Cheers,<br />
Aaron</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Todd</title>
		<link>http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-27149</link>
		<dc:creator><![CDATA[Todd]]></dc:creator>
		<pubDate>Wed, 19 Dec 2007 21:56:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/24/sql-server-comparison-index-fragmentation-index-de-fragmentation-index-rebuild-sql-server-2000-and-sql-server-2005/#comment-27149</guid>
		<description><![CDATA[MSSQL 2005

ALTER INDEX ALL ON dbo.Mail_Messages
REBUILD WITH (FILLFACTOR = 90, SORT_IN_TEMPDB = ON,
STATISTICS_NORECOMPUTE = ON)

I executed the above statement but my fragmentation is still over 85%.  I have used the rebuild and reorg in the maintenance plan also and I cannot get my fragmentation to reduce.

Any suggestions?

Thanks]]></description>
		<content:encoded><![CDATA[<p>MSSQL 2005</p>
<p>ALTER INDEX ALL ON dbo.Mail_Messages<br />
REBUILD WITH (FILLFACTOR = 90, SORT_IN_TEMPDB = ON,<br />
STATISTICS_NORECOMPUTE = ON)</p>
<p>I executed the above statement but my fragmentation is still over 85%.  I have used the rebuild and reorg in the maintenance plan also and I cannot get my fragmentation to reduce.</p>
<p>Any suggestions?</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>
