Rebuild All Indexes On A Database In One Call
Normally I’d leave this sort of thing to a DB to deal with but I stumbled on this a few months back and thought it was rather clever.
EXEC sp_MSforeachtable @command1=”print ‘?'”, @command2=”ALTER INDEX ALL ON ? REBUILD WITH (ONLINE=OFF)”
SELECT * FROM sys.Dm_db_index_physical_stats(Db_id(‘MyDbName’),NULL,NULL,NULL,NULL) — This bit just tells you the results