Querying All Databases With sp_MsForEachDb
If you need to query several databases on same SQL server – you can use undocumented stored procedure sp_MsForEachDb, see Scott Mitchell article Querying a Multi-Tenant Data Architecture for more info and execution examples.
Labels: SQL Server