/****** 對象: 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
---------這是純命令方式。關於這方面的內容還是多看微軟的協助,微軟協助確實做的好。