SQLServer 远程访问方法集合

--启用Ad Hoc Distributed Queries:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure

select * from opendatasource('SQLOLEDB','Data Source=zengfd;UID=sa;Password=1').ticket11.dbo.t_base


--使用完成后,关闭Ad Hoc Distributed Queries:
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure

 


--------------------------------------------------------------------
链接服务器

exec sp_addlinkedserver 'sql132','','SQLOLEDB','10.98.0.132\sql2005'
exec sp_addlinkedsrvlogin 'sql132','false',null,'sa','fangte2005'

 

----------------------------------------------------------------

为Customers表创建一个Synonym,叫MyCustomers。 你可以把这个MyCustomers当作一个普通的表,可以对它进行查询,更新,删除和插入。比如

Create Synonym MyCustomers For SqlTest.Northiwind.dbo.Customers

查询: Select * from MyCustomers.
插入:  Insert into MyCustomers  (CustomersID, CompanyName) values ('Tom', 'MS')
所有的操作,和普通的表没有区别。


相对于Synonym,OpenQuery相对来说,功能就弱了点。其只是在调用其它数据库上的sprocs

select * from openquery([SqlTest], 'exec northwind.dbo.[Customers By City] @param1=N''London''') where CustomerID = 'AROUT'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值