• You can use the undocumented and usupported stored procedure sp_msforeachdb. Actually it has some issues (every now and then it skips a database, to name one), so you can use my replacement you can find here: http://spaghettidba.com/2011/09/09/a-better-sp_msforeachdb/

    -- Gianluca Sartori