sql
USE [master]
GO
/****** Object: LinkedServer [ix5] Script Date: 2023-10-09 10:06:35 ******/
EXEC master.dbo.sp_addlinkedserver @server = N'ix5', @srvproduct=N'', @provider=N'SQLNCLI', @datasrc=N'.'
/* For security reasons the linked server remote logins password is changed with ######## */
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'ix5',@useself=N'False',@locallogin=NULL,@rmtuser=N'publishinternallogin',@rmtpassword='########'
GO
EXEC master.dbo.sp_serveroption @server=N'ix5', @optname=N'collation compatible', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'ix5', @optname=N'data access', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'ix5', @optname=N'dist', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'ix5', @optname=N'pub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'ix5', @optname=N'rpc', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'ix5', @optname=N'rpc out', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'ix5', @optname=N'sub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'ix5', @optname=N'connect timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'ix5', @optname=N'collation name', @optvalue=null
GO
EXEC master.dbo.sp_serveroption @server=N'ix5', @optname=N'lazy schema validation', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'ix5', @optname=N'query timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'ix5', @optname=N'use remote collation', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'ix5', @optname=N'remote proc transaction promotion', @optvalue=N'true'
GO
执行以上语句就可以创建链接服务器,这个只适用我们公司
但在执行的时候需要改一些地方。
sql
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'ix5',@useself=N'False',@locallogin=NULL,@rmtuser=N'publishinternallogin',@rmtpassword='########'
@rmtsrvname=N'ix5' "ix5"就是链接服务器的名称
@rmtuser=N'publishinternallogin' "publishinternallogin"就是登录名,可以写成"sa"
@rmtpassword='########' "########"就是登录名的密码,要写你自己的