标签:
方法一:
select * from servername.dbo.tablename
方法二:
select * from OPENDATASOURCE(
‘SQLOLEDB‘,
‘Data Source=远程ip;User ID=sa;Password=密码‘
).库名.dbo.表名
where 条件
select top 100 * from OPENDATASOURCE(
‘SQLOLEDB‘,
‘Data Source=192.168.6.100;User ID=sa;Password=1234‘
).[zhaolx-test].dbo.TGongwen
where gid <5
insert into OPENDATASOURCE(
‘SQLOLEDB‘,
‘Data Source=192.168.6.100;User ID=sa;Password=1234‘
).[zhaolx-test].dbo.t_aaa (id ,name )values(‘001‘,‘Tom‘)
select top 100 * from OPENDATASOURCE(
‘SQLOLEDB‘,
‘Data Source=192.168.6.100;User ID=sa;Password=1234‘
).[zhaolx-test].dbo.t_aaa
SQL Server实现跨库查询(跨库select insert)
标签:
原文地址:http://www.cnblogs.com/panshengqiang/p/4688519.html