SQL配置链接服务器脚本(SQL Link Server Script)
作者:C/S框架网  发布日期:2018-12-23 21:48:33
  SQL配置链接服务器脚本(SQL Link Server Script)

USE [master]
GO

--创建链接服务器
EXEC master.dbo.sp_addlinkedserver @server = N'LNK_名字', @srvproduct=N'LNK_名字', @provider=N'SQLNCLI', @datasrc=N'服务器IP', @catalog=N'链接的数据库'

--添加SQL账号和密码
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'LNK_名字',@useself=N'False',@locallogin=NULL,@rmtuser=N'SQL账号',@rmtpassword='SQL密码'

GO

--链接服务器配置

EXEC master.dbo.sp_serveroption @server=N'LNK_名字', @optname=N'collation compatible', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'LNK_名字', @optname=N'data access', @optvalue=N'true'
GO

EXEC master.dbo.sp_serveroption @server=N'LNK_名字', @optname=N'dist', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'LNK_名字', @optname=N'pub', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'LNK_名字', @optname=N'rpc', @optvalue=N'true'
GO

EXEC master.dbo.sp_serveroption @server=N'LNK_名字', @optname=N'rpc out', @optvalue=N'true'
GO

EXEC master.dbo.sp_serveroption @server=N'LNK_名字', @optname=N'sub', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'LNK_名字', @optname=N'connect timeout', @optvalue=N'0'
GO

EXEC master.dbo.sp_serveroption @server=N'LNK_名字', @optname=N'collation name', @optvalue=null
GO

EXEC master.dbo.sp_serveroption @server=N'LNK_名字', @optname=N'lazy schema validation', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'LNK_名字', @optname=N'query timeout', @optvalue=N'0'
GO

EXEC master.dbo.sp_serveroption @server=N'LNK_名字', @optname=N'use remote collation', @optvalue=N'true'
GO

EXEC master.dbo.sp_serveroption @server=N'LNK_名字', @optname=N'remote proc transaction promotion', @optvalue=N'true'
GO


点击下载脚本文件:

LINK_SERVER.rar





点击下载附件 点击下载附件 (如下载失败,请邮件通知我们寄回给您,或QQ:23404761留言.)
上一篇 下一篇