EXEC jgmy.dbo.sp_addlinkedserver @server = N ' 192.168.100.230\JIAGONG ' , @srvproduct = N ' SQL Server ' go EXEC jgmy.dbo.sp_addlinkedsrvlogin @rmtsrvname = N ' 192.168.100.230\JIAGONG ' , @locallogin = N ' sa ' , @useself = N ' False ' , @rmtuser = N ' sa ' , @rmtpassword = N ' password ' go declare @ncount int select @ncount = count ( * ) from [ 192.168.100.230\JIAGONG ] . [ machining_trade ] . [ dbo ] . [ outmemo ] where corpid = ' c059 ' print ' 远程数据库上有: ' + cast ( @ncount as char ( 10 )) + ' 条记录 ' select @ncount = count ( * ) from outmemo where corpid = ' c059 ' print ' 本地数据库上有: ' + cast ( @ncount as char ( 10 )) + ' 条记录 ' go sp_dropserver ' 192.168.100.230\JIAGONG ' , ' droplogins ' go sp_linkedservers 转载于:https://www.cnblogs.com/nerozhang/archive/2008/03/10/1098585.html