Thursday, February 26, 2004

Came across some useful undocumented sproc
1)sp_MSforeachtable - it iterates through all the tables of the current DB

Eg.
sp_MSForEachTable 'exec sp_spaceused "?"' -- To get the spaces used by individual sprocs
EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?')" -- To reindex all the tables in the DB

2) And use sp_MSforeachdb to iterated through all the DBs

3) sp_MSdrop_object to drop any object by providing its id/ name etc


No comments: