Karthick P.K on SQL Server

Posts Tagged ‘Script to rebuild index for all tables’

How to rebuild index and update statistics for all the tables in database.

Posted by Karthick P.K on September 26, 2010

EXEC sp_MSforeachtable 'UPDATE STATISTICS ? WITH FULLSCAN'   --  {can be run anytime}

Exec sp_MSforeachtable "dbcc dbreindex('?')"      --- {Always run this on a off-peak hour on any SQL Server instance}



Posted in Optimizer, Performance, SQL General, SQL Query | Tagged: , , , , | 3 Comments »

%d bloggers like this: