SQL Server 创建链接服务器的脚本,自定义链路服务器的简短名称

USE [master]
GO

/****** Object:  LinkedServer [SQL01]    Script Date: 2020/4/9 11:51:17 ******/
EXEC master.dbo.sp_addlinkedserver @server = N'SQL01', @srvproduct=N'', @provider=N'SQLNCLI', @datasrc=N'域名或者IP'
 /* For security reasons the linked server remote logins password is changed with ######## */
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'SQL01',@useself=N'False',@locallogin=NULL,@rmtuser=N'账户',@rmtpassword='密码明文'

GO

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

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

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

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

EXEC master.dbo.sp_serveroption @server=N'SQL01', @optname=N'rpc', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'SQL01', @optname=N'rpc out', @optvalue=N'false'
GO

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

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

EXEC master.dbo.sp_serveroption @server=N'SQL01', @optname=N'collation name', @optvalue=NULL
GO

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

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

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

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



上一篇:sql server临时删除/禁用非聚集索引并重新创建加回/启用的简便编程方法研究对比


下一篇:SqlServer之快速查看表结构(表描述及字段说明)