May 17, 2013 at 5:23 am
HI,
ANY ONE GIVE ME SCRIPT FOR INDEX REBULID AND UPDATE STATISTICS IN SQL 2008 R2
May 17, 2013 at 8:21 am
Index rebuild itself update stats so, you do not have to update stats after index rebuild.
here is one script from web. But if you google it you will find many more., Choose the one which suits you best.
http://sqlfool.com/2009/03/automated-index-defrag-script/
But before implementing this... read through this..
May 17, 2013 at 8:23 am
thank you
May 21, 2013 at 10:58 pm
Another option for automating index and stats maintenance that I highly recommend:
http://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
May 22, 2013 at 12:29 pm
I agree with opc.three. This is one of the best scripts ever.
http://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html
May 22, 2013 at 7:50 pm
The Ola Hollengren scripts are hands down best.
May 23, 2013 at 2:41 am
+1 for Ola Hallengren.
May 23, 2013 at 2:45 am
thanks for all updates
May 23, 2013 at 2:46 am
ReIndex all the Indexes from the Databases.
EXEC sp_msforeachtable @COMMAND1="PRINT '?' DBCC DBREINDEX('?','',80)"
GO
Update all Statistics from the Database.
EXEC SP_UPDATESTATS
GO
May 23, 2013 at 3:08 am
The reason why Ola Hallengren's solution is better than the DBCC REINDEX commands:
- Microsoft recommends doing a reorganize only when fragmentation > 5% and < 30% and even do nothing when fragmentation < 5%, and then even ignore tables with < 10 000 rows.
- DBCC REINDEX syntax is deprecated (SQL 2000 syntax).
Ola Hallengren's script will dynamically choose what to do based on several factors:
- Licensing models (REBUILD ONLINE when possible)
- fragmentation level
- fields in tables (XML fields will prohibit REBUILD ONLINE and force REBUILD OFFLINE)
I have struggled for years with Microsoft Maintenance plans, and when this came along, I have started using it on all my db's. Whorks everytime, it's a no brainer and is even actively supported and updated.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply