/***** Object: linkedserver [202.99.213.226] script Date: 06/26/2007 21:34:35 ******/
Exec master. DBO. sp_addmediaserver @ Server = n'nfdrp', @ srvproduct = n' SQL Server'
/* For security reasons the linked Server Remote logins password is changed ########*/
Exec master. DBO. sp_add1_srvlogin @ 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 valider', @ 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'
The above is the link ServerCodeThe following code deletes the server:
---------------------------
/***** Object: linkedserver [202.99.213.226] script Date: 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'
-----------------------------------
Query example
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
--------- This is a pure command method. For more information about this aspect, see Microsoft's help. Microsoft's help is indeed good.