日期:2014-05-17 浏览次数:20404 次
--192.168.1.1服务器数据库 create database db1 GO use db1 GO create table table1( tid int, tname varchar(50)) GO insert table1(tid,tname) select 1,'子敬' union select 2,'文远' union select 3,'文长' --192.168.1.2服务器数据库 create database db2 GO use db2 GO create table table2( tid int, tname varchar(50)) GO insert table2(tid,tname) select 2,'文远' union select 3,'文长'
exec sp_addlinkedserver 'srv_lnk','','SQLOLEDB','192.168.1.2' exec sp_addlinkedsrvlogin 'srv_lnk','false',null,'sa','123456' select * from table1 left join srv_lnk.db2.dbo.table2 tb2 on table1.tid=tb2.tid exec sp_dropserver 'srv_lnk','droplogins' --删除连接