在sql server 資料庫建立連結的伺服器和刪除

來源:互聯網
上載者:User

/****** 對象:  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
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

---------這是純命令方式。關於這方面的內容還是多看微軟的協助,微軟協助確實做的好。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.