码迷,mamicode.com
首页 > 数据库 > 详细

SQL Server远程连接操作

时间:2017-06-22 22:21:45      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:ted   configure   远程   方法   rowset   color   open   use   rom   

-- 开启远程选项
exec sp_configure ‘show advanced options‘,1
reconfigure
exec sp_configure ‘Ad Hoc Distributed Queries‘,1
reconfigure


-- 方法1:
SELECT top 5 * FROM OPENDATASOURCE(‘SQLOLEDB‘,‘Data Source=192.168.2.208;User ID=sa;Password=ccpg@2015‘).[CCPG_PM].dbo.[COM_UserInfo] P where p.[GC_Flag]=0

-- 方法2:
SELECT top 5 * FROM OPENROWSET(‘SQLNCLI‘,‘192.168.2.208‘;‘sa‘;‘ccpg@2015‘,‘select * from [CCPG_PM].dbo.[COM_UserInfo] P where p.[GC_Flag]=0‘) AS a


-- 关闭远程选项
exec sp_configure ‘Ad Hoc Distributed Queries‘,0 
reconfigure 
exec sp_configure ‘show advanced options‘,0 
reconfigure

 

SQL Server远程连接操作

标签:ted   configure   远程   方法   rowset   color   open   use   rom   

原文地址:http://www.cnblogs.com/hllive/p/7067459.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!