Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All
I have a database named 'Master_Database'
It contain a table named 'tblDatabases'.
tblDatabases has a column 'DatabaseName' which contain data as
Database1
Database2
Database3

I have three databases named Database1,Database2,Database3
All of them have a table 'tblEmployees'

Now i want to fetch records from 'tblEmployees' table from all databases whose name are present in 'tblDatabases' table of 'Master_Database'

Thanks in advance
Richa Sharma
Posted
Updated 31-Jul-12 3:15am
v2

1 solution

Hello @Richa

I Think I might me possible with the query :

SQL
SELECT * FROM Database1.dbo.tblEmployees, Database2.dbo.tblEmployees, Database3.dbo.tblEmployees


Hope this will help you..
 
Share this answer
 
Comments
Sharma Richa 18-Mar-12 23:57pm    
Problem is that i have to pick these database1,database2,database3 .....so on from 'Master_Database' dynamically

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900