USE 数据库1
select * from table1
USE 数据库2
select * from table1
USE 数据库3
select * from table1可否写成一条语句,如 
  use 数据库1,数据库2,数据库3
  select * from table1

解决方案 »

  1.   

    写成视图吧 create view v_table
    as
    select * from 数据库1..table1
    union all
    select * from 数据库2..table1
    union all
    select * from 数据库3..table1
      

  2.   

    select * from 数据库1.dbo.table1
    select * from 数据库2.dbo.table1
    select * from 数据库3.dbo.table1
      

  3.   

    select * from 数据库1.dbo.table1
    union all
    select * from 数据库2.dbo.table1
    union all 
    select * from 数据库3.dbo.table1
      

  4.   


    use 数据库1
    select a.*,b.*,c.* from table1 a,数据库2.dbo.table2 b,数据库3.dbo.table3 c