下面为您介绍如何在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
---------这是纯命令方式。关于这方面的内容还是多看微软的帮助,微软帮助确实做的好。
新闻名称:SQL server建立链接服务器和删除服务器链接
本文网址:http://www.mswzjz.cn/qtweb/news29/350879.html
攀枝花网站建设、攀枝花网站运维推广公司-贝锐智能,是专注品牌与效果的网络营销公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 贝锐智能