<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>sp_updatestats &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/sp_updatestats/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Wed, 26 Jul 2017 19:25:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>SQL Server: Script to execute Update Statistics for all Databases</title>
		<link>https://www.dbrnd.com/2017/08/sql-server-script-to-execute-update-statistics-for-all-databases-sp_updatestats/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 04 Aug 2017 16:16:20 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[sp_updatestats]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5749</guid>

					<description><![CDATA[In this post, I am building a script to execute Update Statistics (sp_updatestats) for all SQL Server Databases. DBA set auto update statistics to ON, but then also some times DBA has to execute sp_updatestats for updating the Database Statistics. When high volumes of data processing, Auto update option skips updating the database statistics so [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-script-to-execute-update-statistics-for-all-databases-sp_updatestats%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20execute%20Update%20Statistics%20for%20all%20Databases" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-script-to-execute-update-statistics-for-all-databases-sp_updatestats%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20execute%20Update%20Statistics%20for%20all%20Databases" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-script-to-execute-update-statistics-for-all-databases-sp_updatestats%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20execute%20Update%20Statistics%20for%20all%20Databases" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-script-to-execute-update-statistics-for-all-databases-sp_updatestats%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20execute%20Update%20Statistics%20for%20all%20Databases" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-script-to-execute-update-statistics-for-all-databases-sp_updatestats%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20execute%20Update%20Statistics%20for%20all%20Databases" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-script-to-execute-update-statistics-for-all-databases-sp_updatestats%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20execute%20Update%20Statistics%20for%20all%20Databases" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-script-to-execute-update-statistics-for-all-databases-sp_updatestats%2F&#038;title=SQL%20Server%3A%20Script%20to%20execute%20Update%20Statistics%20for%20all%20Databases" data-a2a-url="https://www.dbrnd.com/2017/08/sql-server-script-to-execute-update-statistics-for-all-databases-sp_updatestats/" data-a2a-title="SQL Server: Script to execute Update Statistics for all Databases"></a></p><p>In this post, I am building a script to execute Update Statistics (sp_updatestats) for all SQL Server Databases. </p>
<p>DBA set auto update statistics to ON, but then also some times DBA has to execute sp_updatestats for updating the Database Statistics. </p>
<p>When high volumes of data processing, Auto update option skips updating the database statistics so DBA has to update database statistics in a maintenance window. </p>
<blockquote data-secret="9lanpaOcZ9" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2016/12/sql-server-enable-auto-create-and-auto-update-statistics/">SQL Server: Enable Auto Create and Auto Update Statistics</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/12/sql-server-enable-auto-create-and-auto-update-statistics/embed/#?secret=9lanpaOcZ9" data-secret="9lanpaOcZ9" width="600" height="338" title="&#8220;SQL Server: Enable Auto Create and Auto Update Statistics&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>DBA can use below script to execute sp_updatestats for all databases:</strong></p>
<pre class="crayon-plain-tag">DECLARE @SQL VARCHAR(1000)  
DECLARE @DBName sysname  

DECLARE DBcur CURSOR FORWARD_ONLY STATIC FOR  
SELECT [name]  
FROM master..sysdatabases 
WHERE [name] NOT IN ('master','model', 'tempdb') 
ORDER BY [name] 
     
OPEN DBcur  
FETCH NEXT FROM DBcur INTO @DBName  
WHILE @@FETCH_STATUS = 0  
   BEGIN  
       SELECT @SQL = 'USE [' + @DBName +']' + CHAR(13) + 'EXEC sp_updatestats' + CHAR(13)  
       PRINT @SQL  
       FETCH NEXT FROM DBcur INTO @DBName  
   END      
CLOSE DBcur  
DEALLOCATE DBcur</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: sp_updatestats to update the Database Statistics</title>
		<link>https://www.dbrnd.com/2016/12/sql-server-sp_updatestats-to-update-the-database-statistics/</link>
					<comments>https://www.dbrnd.com/2016/12/sql-server-sp_updatestats-to-update-the-database-statistics/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 19 Dec 2016 19:47:04 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[sp_updatestats]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=2501</guid>

					<description><![CDATA[In this post, I am sharing scripts to update a statistic of an individual object or all the objects in SQL Server. In the query execution process, Query Optimizer uses a statistic of objects to get different information like: number of actual rows, index information, data change count and others. The database statistic helps to [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-sp_updatestats-to-update-the-database-statistics%2F&amp;linkname=SQL%20Server%3A%20sp_updatestats%20to%20update%20the%20Database%20Statistics" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-sp_updatestats-to-update-the-database-statistics%2F&amp;linkname=SQL%20Server%3A%20sp_updatestats%20to%20update%20the%20Database%20Statistics" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-sp_updatestats-to-update-the-database-statistics%2F&amp;linkname=SQL%20Server%3A%20sp_updatestats%20to%20update%20the%20Database%20Statistics" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-sp_updatestats-to-update-the-database-statistics%2F&amp;linkname=SQL%20Server%3A%20sp_updatestats%20to%20update%20the%20Database%20Statistics" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-sp_updatestats-to-update-the-database-statistics%2F&amp;linkname=SQL%20Server%3A%20sp_updatestats%20to%20update%20the%20Database%20Statistics" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-sp_updatestats-to-update-the-database-statistics%2F&amp;linkname=SQL%20Server%3A%20sp_updatestats%20to%20update%20the%20Database%20Statistics" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-sp_updatestats-to-update-the-database-statistics%2F&#038;title=SQL%20Server%3A%20sp_updatestats%20to%20update%20the%20Database%20Statistics" data-a2a-url="https://www.dbrnd.com/2016/12/sql-server-sp_updatestats-to-update-the-database-statistics/" data-a2a-title="SQL Server: sp_updatestats to update the Database Statistics"></a></p><p>In this post, I am sharing scripts to update a statistic of an individual object or all the objects in SQL Server.</p>
<blockquote><p>In the query execution process, Query Optimizer uses a statistic of objects to get different information like: number of actual rows, index information, data change count and others.<br />
The database statistic helps to the Query Optimizer in choosing a best execution plan for query processing.</p></blockquote>
<p><strong>Why object statistic should be updated?</strong></p>
<blockquote><p>The Query Optimer choose an execution plan accordingly statistical data.<br />
For example, Your table has an actual row count is 100000 and imagine that statistic object is not updated and has only a 50000 row count, so with this situation, it may be selects a wrong execution plan.</p></blockquote>
<blockquote><p>To update a Statistic of Tables and Indexes is also one type of maintenance task for DBA and it should be performed periodically.</p></blockquote>
<p><strong>Update all statistic of a Database:</strong><br />
<pre class="crayon-plain-tag">EXEC sp_updatestats;</pre>
<strong>Update statistic of a Table:</strong><br />
<pre class="crayon-plain-tag">UPDATE STATISTICS Table_Name</pre>
<strong>Update statistic of an Index:</strong><br />
<pre class="crayon-plain-tag">UPDATE STATISTICS Table_Name Index_Name</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/12/sql-server-sp_updatestats-to-update-the-database-statistics/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
