<?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; Guest Post by Sandip Pani &#8211; SQL Server Statistics Name and Index Creation</title>
	<atom:link href="http://blog.sqlauthority.com/2012/09/17/sql-server-guest-post-by-sandip-pani-sql-server-statistics-name-and-index-creation/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2012/09/17/sql-server-guest-post-by-sandip-pani-sql-server-statistics-name-and-index-creation/</link>
	<description>SQL, SQL Server, MySQL, Big Data and NoSQL</description>
	<lastBuildDate>Wed, 19 Jun 2013 21:45:15 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Chitra</title>
		<link>http://blog.sqlauthority.com/2012/09/17/sql-server-guest-post-by-sandip-pani-sql-server-statistics-name-and-index-creation/#comment-407589</link>
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Mon, 14 Jan 2013 13:00:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=20734#comment-407589</guid>
		<description><![CDATA[I find this very useful in understanding about statistics]]></description>
		<content:encoded><![CDATA[<p>I find this very useful in understanding about statistics</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DeepakM</title>
		<link>http://blog.sqlauthority.com/2012/09/17/sql-server-guest-post-by-sandip-pani-sql-server-statistics-name-and-index-creation/#comment-367855</link>
		<dc:creator><![CDATA[DeepakM]]></dc:creator>
		<pubDate>Fri, 02 Nov 2012 09:36:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=20734#comment-367855</guid>
		<description><![CDATA[Good point! It&#039;s easy to miss this check while creating indexes.]]></description>
		<content:encoded><![CDATA[<p>Good point! It&#8217;s easy to miss this check while creating indexes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shiva</title>
		<link>http://blog.sqlauthority.com/2012/09/17/sql-server-guest-post-by-sandip-pani-sql-server-statistics-name-and-index-creation/#comment-366486</link>
		<dc:creator><![CDATA[shiva]]></dc:creator>
		<pubDate>Tue, 30 Oct 2012 12:11:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=20734#comment-366486</guid>
		<description><![CDATA[very useful:) Thanks]]></description>
		<content:encoded><![CDATA[<p>very useful:) Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Suzanne</title>
		<link>http://blog.sqlauthority.com/2012/09/17/sql-server-guest-post-by-sandip-pani-sql-server-statistics-name-and-index-creation/#comment-366166</link>
		<dc:creator><![CDATA[Suzanne]]></dc:creator>
		<pubDate>Mon, 29 Oct 2012 13:55:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=20734#comment-366166</guid>
		<description><![CDATA[Very useful!]]></description>
		<content:encoded><![CDATA[<p>Very useful!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mahesh Babu</title>
		<link>http://blog.sqlauthority.com/2012/09/17/sql-server-guest-post-by-sandip-pani-sql-server-statistics-name-and-index-creation/#comment-353206</link>
		<dc:creator><![CDATA[Mahesh Babu]]></dc:creator>
		<pubDate>Wed, 26 Sep 2012 07:55:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=20734#comment-353206</guid>
		<description><![CDATA[Once we drop the index, its stats also get dropped automatically which was created with the same name as index. So i think we dont need to drop stats
manually.]]></description>
		<content:encoded><![CDATA[<p>Once we drop the index, its stats also get dropped automatically which was created with the same name as index. So i think we dont need to drop stats<br />
manually.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lohithkschalam</title>
		<link>http://blog.sqlauthority.com/2012/09/17/sql-server-guest-post-by-sandip-pani-sql-server-statistics-name-and-index-creation/#comment-349987</link>
		<dc:creator><![CDATA[lohithkschalam]]></dc:creator>
		<pubDate>Mon, 17 Sep 2012 14:53:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=20734#comment-349987</guid>
		<description><![CDATA[Real good post.................]]></description>
		<content:encoded><![CDATA[<p>Real good post&#8230;&#8230;&#8230;&#8230;&#8230;..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tarun Sharma</title>
		<link>http://blog.sqlauthority.com/2012/09/17/sql-server-guest-post-by-sandip-pani-sql-server-statistics-name-and-index-creation/#comment-349959</link>
		<dc:creator><![CDATA[Tarun Sharma]]></dc:creator>
		<pubDate>Mon, 17 Sep 2012 13:56:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=20734#comment-349959</guid>
		<description><![CDATA[Indeed Insightful.]]></description>
		<content:encoded><![CDATA[<p>Indeed Insightful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2012/09/17/sql-server-guest-post-by-sandip-pani-sql-server-statistics-name-and-index-creation/#comment-349832</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Mon, 17 Sep 2012 08:08:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=20734#comment-349832</guid>
		<description><![CDATA[Done and modified the code as per your request.]]></description>
		<content:encoded><![CDATA[<p>Done and modified the code as per your request.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2012/09/17/sql-server-guest-post-by-sandip-pani-sql-server-statistics-name-and-index-creation/#comment-349831</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Mon, 17 Sep 2012 08:07:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=20734#comment-349831</guid>
		<description><![CDATA[Excellent point Aasim!]]></description>
		<content:encoded><![CDATA[<p>Excellent point Aasim!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aasim abdullah</title>
		<link>http://blog.sqlauthority.com/2012/09/17/sql-server-guest-post-by-sandip-pani-sql-server-statistics-name-and-index-creation/#comment-349824</link>
		<dc:creator><![CDATA[aasim abdullah]]></dc:creator>
		<pubDate>Mon, 17 Sep 2012 07:37:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=20734#comment-349824</guid>
		<description><![CDATA[Pinal, Please remove &quot;SELECT 1&quot;

that was add to test code]]></description>
		<content:encoded><![CDATA[<p>Pinal, Please remove &#8220;SELECT 1&#8243;</p>
<p>that was add to test code</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aasim abdullah</title>
		<link>http://blog.sqlauthority.com/2012/09/17/sql-server-guest-post-by-sandip-pani-sql-server-statistics-name-and-index-creation/#comment-349803</link>
		<dc:creator><![CDATA[aasim abdullah]]></dc:creator>
		<pubDate>Mon, 17 Sep 2012 06:57:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=20734#comment-349803</guid>
		<description><![CDATA[SQL Server keeps track of user created statistics through a bit in sys.stats i.e. user_created. That&#039;s why while creating a new index, to avoid this error, we must add following IF EXISTS() code, before actual index creation code.

IF EXISTS ( SELECT  *
            FROM    sys.indexes
            WHERE   name = N&#039;IX_TestTable_1&#039;
                    AND object_id = OBJECT_ID(N&#039;[dbo].[TestTable]&#039;) ) 
    DROP INDEX [dbo].[TestTable].[IX_TestTable_1]     
GO       
IF EXISTS ( SELECT  *
            FROM    sys.stats
            WHERE   name = N&#039;IX_TestTable_1&#039;
                    AND object_id = OBJECT_ID(N&#039;[dbo].[TestTable]&#039;)
                    AND user_created = 1 ) 
DROP STATISTICS [dbo].[TestTable].[IX_TestTable_1]  
GO

CREATE NONCLUSTERED INDEX IX_TestTable_1 ON TestTable(Col1)

One must keep in mind that, only user created stats can be dropped, so if we just check existence of stats through name, it will return TRUE, but when it will try to drop that statistics, it will give following error.
Cannot DROP the index &#039;[dbo].[TestTable].[IX_TestTable_1]&#039; because it is not a statistics collection.]]></description>
		<content:encoded><![CDATA[<p>SQL Server keeps track of user created statistics through a bit in sys.stats i.e. user_created. That&#8217;s why while creating a new index, to avoid this error, we must add following IF EXISTS() code, before actual index creation code.</p>
<p>IF EXISTS ( SELECT  *<br />
            FROM    sys.indexes<br />
            WHERE   name = N&#8217;IX_TestTable_1&#8242;<br />
                    AND object_id = OBJECT_ID(N&#8217;[dbo].[TestTable]&#8216;) )<br />
    DROP INDEX [dbo].[TestTable].[IX_TestTable_1]<br />
GO<br />
IF EXISTS ( SELECT  *<br />
            FROM    sys.stats<br />
            WHERE   name = N&#8217;IX_TestTable_1&#8242;<br />
                    AND object_id = OBJECT_ID(N&#8217;[dbo].[TestTable]&#8216;)<br />
                    AND user_created = 1 )<br />
DROP STATISTICS [dbo].[TestTable].[IX_TestTable_1]<br />
GO</p>
<p>CREATE NONCLUSTERED INDEX IX_TestTable_1 ON TestTable(Col1)</p>
<p>One must keep in mind that, only user created stats can be dropped, so if we just check existence of stats through name, it will return TRUE, but when it will try to drop that statistics, it will give following error.<br />
Cannot DROP the index &#8216;[dbo].[TestTable].[IX_TestTable_1]&#8216; because it is not a statistics collection.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rainmaker</title>
		<link>http://blog.sqlauthority.com/2012/09/17/sql-server-guest-post-by-sandip-pani-sql-server-statistics-name-and-index-creation/#comment-349760</link>
		<dc:creator><![CDATA[Rainmaker]]></dc:creator>
		<pubDate>Mon, 17 Sep 2012 05:28:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=20734#comment-349760</guid>
		<description><![CDATA[I think we should not only build statistics.]]></description>
		<content:encoded><![CDATA[<p>I think we should not only build statistics.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yangamuniprasad</title>
		<link>http://blog.sqlauthority.com/2012/09/17/sql-server-guest-post-by-sandip-pani-sql-server-statistics-name-and-index-creation/#comment-349724</link>
		<dc:creator><![CDATA[yangamuniprasad]]></dc:creator>
		<pubDate>Mon, 17 Sep 2012 02:48:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=20734#comment-349724</guid>
		<description><![CDATA[Excellent article by Sandip Pani.  thanks pinal for sharing such an article to public.. 

I appreciate your efforts and keep posting like these guest articles and encouraging the hidden talents of many people. 

Thanks,
Prasad]]></description>
		<content:encoded><![CDATA[<p>Excellent article by Sandip Pani.  thanks pinal for sharing such an article to public.. </p>
<p>I appreciate your efforts and keep posting like these guest articles and encouraging the hidden talents of many people. </p>
<p>Thanks,<br />
Prasad</p>
]]></content:encoded>
	</item>
</channel>
</rss>
