SQL server建立链接服务器和删除服务器链接

数据库 SQL Server
下面为您介绍如何在SQL server中建立链接服务器和删除服务器链接,供您参考,如果您对此有兴趣的话,不妨一看,相信会对您有所帮助。

下面为您介绍如何在SQL server中建立链接服务器和删除服务器链接,供您参考,如果您对此有兴趣的话,不妨一看,相信会对您有所帮助。

/****** 对象:  LinkedServer [202.99.213.226]    脚本日期: 06/26/2007 21:34:35 ******/
EXEC master.dbo.sp_addlinkedserver @server = N'NFDRP', @srvproduct=N'SQL Server'
 /* For security reasons the linked server remote logins password is changed with ######## */
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'202.99.213.226',@useself=N'False',@locallogin=NULL,@rmtuser=N'sa',@rmtpassword='########'

GO
EXEC master.dbo.sp_serveroption @server=N'202.99.213.226', @optname=N'collation compatible', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'202.99.213.226', @optname=N'data access', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'202.99.213.226', @optname=N'dist', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'202.99.213.226', @optname=N'pub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'202.99.213.226', @optname=N'rpc', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'202.99.213.226', @optname=N'rpc out', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'202.99.213.226', @optname=N'sub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'202.99.213.226', @optname=N'connect timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'202.99.213.226', @optname=N'collation name', @optvalue=null#p#
GO
EXEC master.dbo.sp_serveroption @server=N'202.99.213.226', @optname=N'lazy schema validation', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'202.99.213.226', @optname=N'query timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'202.99.213.226', @optname=N'use remote collation', @optvalue=N'false'


上面是建立链接服务器的代码,下面是删除服务器的代码
---------------------------
/****** 对象:  LinkedServer [202.99.213.226]    脚本日期: 06/26/2007 21:50:58 ******/
IF  EXISTS (SELECT srvname FROM master.dbo.sysservers srv WHERE srvid != 0 AND srvname = N'202.99.213.226')EXEC master.dbo.sp_dropserver @server=N'202.99.213.226', @droplogins='droplogins'


-----------------------------------
查询示例
select * from [202.99.213.226].nafine1129.dbo.biarea

---------------------
SELECT top 10 *
FROM
OPENDATASOURCE('SQLOLEDB','Data Source=202.99.213.226;User ID=sa;Password=nafineyxb').nafine1129.dbo.biarea

---------这是纯命令方式。关于这方面的内容还是多看微软的帮助,微软帮助确实做的好。

责任编辑:段燃 来源: 博客园
相关推荐

2023-11-29 07:34:25

2022-10-21 08:32:43

2010-11-08 17:20:54

SQL Server跨

2010-09-01 17:07:08

Sql删除服务器

2011-08-15 08:57:11

SQL Server链接服务器DB2

2011-02-23 17:47:15

限制vsFTP链接

2010-10-22 13:56:41

SQL Server服

2010-11-09 14:47:46

SQL Server跨

2010-11-08 11:53:16

2010-10-20 15:53:37

SQL Server服

2010-09-03 13:21:01

SQL删除

2011-07-27 13:52:02

Oracle数据库远程服务器

2022-03-11 06:47:30

MSSQL数据库MySQL

2011-03-04 15:19:50

VsFTP

2010-09-06 17:08:23

2011-08-11 17:25:24

MSSQL链接服务器Oracle数据库

2011-09-15 13:24:15

SQL Server性能监视

2009-04-03 15:14:42

微软优化SQL Server

2010-09-28 15:24:13

Windows Ser

2010-07-21 11:29:24

点赞
收藏

51CTO技术栈公众号