exec sp_addlinkedserver 'ITSV','','SQLOLEDB','远程服务器名或ip地址'
exec sp_addlinkedsrvlogin 'ITSV','false',null,'用户名','密码'
exec sp_dropserver 'ITSV' , ' droplogins ' --关闭连接
select * from openrowset ( 'SQLOLEDB' , 'sql服务器名' ; '用户名' ; '密码',数据库名.dbo.表名)
ps:删除重复数据
--第一步:先找到重复数据 select ProcInstID from record_errorlog group by ProcInstID having count(ProcInstID) > 1 --查看一下 select * from record_errorlog where ProcInstID in (select ProcInstID from record_errorlog group by ProcInstID having count(ProcInstID) > 1); --第二部 保留ErrorLogID最大的(也就是最新的数据) delete from record_errorlog where ProcInstID in (select ProcInstID from record_errorlog group by ProcInstID having count(ProcInstID) > 1) and ErrorLogID not in (select max(ErrorLogID) from record_errorlog group by ProcInstID having count(ProcInstID )>1);