exec sp_MsForEachDB 'SELECT "?", 1'

The ? will be replaced by the current database name. To run a query that references a table, you need to make sure that the table exists first, as this query will run on system databases as well.