建立SQL链接服务器

  

 

  访问链接服务器的格式:select * from [IPMLBZ].[数据库].[dbo].WEB_ItemInfo

 

  有一个最简单的方法就是直接鼠标新建,这样是以ip为开头的,也可以通过下面的代码进行创建,这样的话就可以换名字了。。。。。。

@server名字全部改为你的链接服务器名字,@datasec改为链接服务器实例名,@rmtpassword改为登陆密码,完事~

USE [master]
GO

/****** Object:  LinkedServer [IPDYH]    Script Date: 2018/2/9 9:11:53 ******/
EXEC master.dbo.sp_addlinkedserver @server = N'IPDYH', @srvproduct=N' ', @provider=N'SQLNCLI', @datasrc=N'192.168.0.16\QYDYHMSSQL'
 /* For security reasons the linked server remote logins password is changed with ######## */
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'IPDYH',@useself=N'False',@locallogin=NULL,@rmtuser=N'sa',@rmtpassword='@KTYpms123'
GO

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

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

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

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

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

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

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

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

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

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

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

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

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

 

posted @ 2018-02-09 11:02  蜀云泉  阅读(425)  评论(0编辑  收藏  举报