May 3, 2011 at 7:56 am
Hi All,
can anyone let me know the query to update all the statistics in a specific database.Its very urgent.please help me on this..
Thanks in advance,
vamshi.
May 3, 2011 at 7:59 am
i need that query which has to be work on SQL server 2005
May 3, 2011 at 8:03 am
exec sp_MSforeachtable 'UPDATE STATISTICS [?] WITH FULLSCAN'
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
May 3, 2011 at 8:04 am
Cute way of doing it without loops or sp_MSForeachTable
You may want to change the sampling rate.
Also keep in mind that this takes ± 30 minutes to run on my 18 GB DB. And all things considered we have a very well tuned server / san. even if it seems underpowered (1 xeon CPU, 2 cores, 4 GB RAM)!
DECLARE @Exec VARCHAR(MAX)
SELECT @Exec = ''
SELECT @Exec = 'UPDATE STATISTICS dbo.[' + CONVERT(VARCHAR(200),name) + '] WITH FULLSCAN ; ' + CHAR(13) + CHAR(10) + @Exec FROM sys.tables ORDER BY name DESC
PRINT LEN(@Exec)
PRINT @Exec
EXEC(@Exec)
May 3, 2011 at 8:21 am
Thank you very much.It is working perfectly..
DECLARE @Exec VARCHAR(MAX)
SELECT @Exec = ''
SELECT @Exec = 'UPDATE STATISTICS dbo.[' + CONVERT(VARCHAR(200),name) + '] WITH FULLSCAN ; ' + CHAR(13) + CHAR(10) + @Exec FROM sys.tables ORDER BY name DESC
PRINT LEN(@Exec)
PRINT @Exec
EXEC(@Exec)
May 3, 2011 at 8:26 am
As I said it's a cute way to do it. My first answer was foreachtable but Gail had come up with it... 😉
May 3, 2011 at 10:02 am
you can use SQL Server BI Development Tool with the help of SSIS package as shown in the attachements
Regards,
Syed Jahanzaib Bin Hassan
MCTS | MCITP | OCA | OCP | OCE | SCJP | IBMCDBA
My Blog
Regards,
Syed Jahanzaib Bin Hassan
BSCS | MCTS | MCITP | OCA | OCP | OCE | SCJP | IBMCDBA
My Blog
www.aureus-salah.com
May 3, 2011 at 10:05 am
I've always preffered to stay away from maint. plans. They've been too buggy, unreliable and hard if not impossible to adjust to very specific needs.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply