[
From MSSQLTips]
There are times when I find myself needing to run a SQL command against each database on one of my SQL Server instances. There is a handy undocumented stored procedure that allows you to do this without needing to set up a cursor against your sysdatabases table in the master database: sp_MSforeachdb.
The article continues at
http://www.mssqltips.com/tip.asp?tip=1414