问题描述
大家好
我有一个名为''Master_Database''的数据库
它包含一个名为``tblDatabases''的表.
tblDatabases具有一列"DatabaseName",其中包含的数据为
数据库1
数据库2
数据库3
我有三个名为Database1,Database2,Database3的数据库
他们都有一张表"tblEmployees"
现在我想从名称在"Master_Database"的"tblDatabases"表中出现的所有数据库中,从"tblEmployees"表中获取记录.
在此先感谢
Richa Sharma
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
推荐答案
SELECT * FROM Database1.dbo.tblEmployees, Database2.dbo.tblEmployees, Database3.dbo.tblEmployees
希望这会对您有所帮助.
Hope this will help you..
这篇关于从多个表中选择数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!