-- The default parameters & conventions are used.
-- More options are available like pre / post-command & other parameter markers
--
-- Examples to perform a command in each database
exec sp_MSforeachdb 'Use [?] exec sp_spaceused'
exec sp_MSforeachdb 'dbcc checkdb(''?'') with no_infomsgs'

-- Example to perform a command on each table in the database
exec sp_MSforeachtable 'exec sp_spaceused ''?'''
exec sp_MSforeachtable 'declare @id int select @id = object_id(''?'')
                                dbcc showcontig(@id) print '''''
exec sp_MSforeachtable 'dbcc checktable(''?'') with no_infomsgs'
exec sp_MSforeachtable 'dbcc updateusage(0, ''?'') with no_infomsgs'
This page was last updated on May 01, 2006 04:28 PM.