Iterating Databases

Sometimes when doing System Administration tasks it is tempting to use sp_msforeachdb, however this is actually undocumented, so missing from MSDN and really should be used with extreme caution. Most of these System Administration tasks should probably be done with PowerShell but if you think you need to use sp_msforeachdb then read sp_msforeachdb: Improving on an Undocumented Stored Procedure - SQLServerCentral for an alternative.