Monthly Archives: November 2009

using sp_msforeachdb

I really like sp_msforeachdb. For example, here is the sql to my regular maintenance jobs: exec sp_MSforeachdb ‘DBCC CHECKDB(?) with NO_INFOMSGS, ALL_ERRORMSGS’ exec sp_msforeachdb ‘if db_id(”?”) <> db_id(”master”) and db_id(”?”) <> db_id(”tempdb”) begin use [?];exec sp_dbreindex_or_indexdefrag;end’ exec sp_msforeachdb ‘if db_id(”?”) … Continue reading

Posted in Day to day, DBA | Leave a comment