sql - How to query data of a specific table in all the databases without going into the database individually? -


one of clients has following setup in sql server environments: each of customers has own database, called customer1db, customer2db, , on. each of these databases has same tables , same structure, different data.

let's there tablea , columna in databases. there way query data in columna in each of these databases without doing

select columna tablea  

in each of databases?

execute master.sys.sp_msforeachdb  'use [?];   if db_id()>4    begin  select col dbo.tbl  end' 

the above exclude system db's. can change query exclude more


Comments

Popular posts from this blog

angular - DownloadURL return null in below code -

meteor - inserting data to database gives error "insert failed: Method '/texts/insert' not found" -