I'm not exactly sure what you are doing but you can hit all the databases on a server via sp_msforeachdb. It's an undocumented stored procedure but there is plenty of information on it via Google.