SQL Server新建LinkServer
------------恢复内容开始------------
/****** Object: LinkedServer [AAAA] Script Date: 04/10/2020 10:37:44 ******/
EXEC master.dbo.sp_addlinkedserver @server = N'AAAA', @srvproduct=N'AAAA', @provider=N'SQLNCLI', @datasrc=N'XXXX'
--Linkserver名: AAAA @datasrc 可以是IP,也可以是电脑名(建立IP方式的LinkServer,需要固定IP,以防IP被抢走。)
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'AAAA',@useself=N'False',@locallogin=NULL,@rmtuser=N'sa',@rmtpassword='########'
GO
--@rmtuser:用户名 @rmtpassword:密码
EXEC master.dbo.sp_serveroption @server=N'AAAA', @optname=N'collation compatible', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'AAAA', @optname=N'data access', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'AAAA', @optname=N'dist', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'AAAA', @optname=N'pub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'AAAA', @optname=N'rpc', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'AAAA', @optname=N'rpc out', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'AAAA', @optname=N'sub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'AAAA', @optname=N'connect timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'AAAA', @optname=N'collation name', @optvalue=null
GO
EXEC master.dbo.sp_serveroption @server=N'AAAA', @optname=N'lazy schema validation', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'AAAA', @optname=N'query timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'AAAA', @optname=N'use remote collation', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'AAAA', @optname=N'remote proc transaction promotion', @optvalue=N'true'
GO
------------恢复内容结束------------