Monday, April 18, 2011

sp_MSforeachtable

You can use the sp_MSforeachtable undocumented system stored procedure to accomplish tasks on all tables of a database such as rebuilding indexes or recomputing statistics. This script rebuilds all indexes with a fillfactor of 80 in every table in the pubs database: USE pubs GO EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', ' ', 80)" GO

No comments:

Post a Comment