﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Administering / SQL Server 2005  / Script to show the statistics from all user tables from a DB / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 23:59:02 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Script to show the statistics from all user tables from a DB</title><link>http://www.sqlservercentral.com/Forums/Topic1404717-146-1.aspx</link><description>Excelent!I was working in this for hours... and I can't resolve the problem... :hehe:thanks a lot!</description><pubDate>Wed, 09 Jan 2013 08:34:03 GMT</pubDate><dc:creator>Seed Vicious</dc:creator></item><item><title>RE: Script to show the statistics from all user tables from a DB</title><link>http://www.sqlservercentral.com/Forums/Topic1404717-146-1.aspx</link><description>nice effort!just as a more streamlined form, you don't need a cursor to generate the same results:you can do it as a single set based operation instead:[code]SELECT object_schema_name(OBJECT_ID) as SchemaName,object_name(OBJECT_ID) as Objeto, STATS_DATE(OBJECT_ID,STATS_ID) StatDate,* FROM SYS.STATS WHERE OBJECT_ID IN(SELECT object_id from sys.tables)order by   object_schema_name(OBJECT_ID),  object_name(OBJECT_ID),  stats_id[/code]</description><pubDate>Wed, 09 Jan 2013 07:17:37 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>Script to show the statistics from all user tables from a DB</title><link>http://www.sqlservercentral.com/Forums/Topic1404717-146-1.aspx</link><description>Enjoy! :-D[code="sql"]Set nocount onDECLARE crComando CURSOR READ_ONLY FOR select name from sys.objects where type = 'u' order by nameDECLARE @name varchar(400)OPEN crComandoFETCH NEXT FROM crComando INTO @nameWHILE (@@fetch_status &amp;lt;&amp;gt; -1)BEGIN	IF (@@fetch_status &amp;lt;&amp;gt; -2)	BEGIN			DECLARE @message varchar(8000)		SELECT @message = 'SELECT '''+@name +''' as Objeto, STATS_DATE(OBJECT_ID,STATS_ID) StatDate,* FROM SYS.STATS WHERE OBJECT_ID = OBJECT_ID('''+@name +''')' 		--PRINT @message		Exec(@message)			END	FETCH NEXT FROM crComando INTO @nameENDCLOSE crComandoDEALLOCATE crComando[/code]</description><pubDate>Wed, 09 Jan 2013 05:51:54 GMT</pubDate><dc:creator>Seed Vicious</dc:creator></item></channel></rss>