数据库a中有表a1
数据库b中有表b1
a1和表b1中由字段id来连接,请问怎么写sql语句
谢谢啊

解决方案 »

  1.   

    例如:
    select * from a.dbo.a1 t1 ,b.dbo.b1 where t1.id=t2.id名称格式: 
    数据库名.所有者名.表名
      

  2.   

    例如:
    select * from a.dbo.a1 t1 ,b.dbo.b1 t2 where t1.id=t2.id名称格式: 
    数据库名.所有者名.表名
      

  3.   

    select A.*,B.*
    from a.dbo.a1 A,b.dbo.b1 B
    where A.id=B.id好像是这样~~~
      

  4.   

    在同一服务器
     select * from a.dbo.a1 a,b.dbo.b1 b where a.id=b.id
    不同服务器
    select * from openrowset('sqloledb','a数据库服务器名或者ip';'sa';'密码',a.dbo.a1) a,b.dbo.b1 b where a.id=b.id