欢迎光临阿斌的博客! QQ:496087321 更多精彩请访问:谢斌个人博客

SQL SERVER 执行远端数据库的SQL命令

------------------------------------------------------------
--这段先执行
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
------------------------------------------------------------

 

 

--这里写要执行的SQL语句
select *
from opendatasource('SQLOLEDB','server={server};uid={uid};pwd={pwd}').[DataBaseName].dbo.TableName

 

 

------------------------------------------------------------
--语句运行完以后执行这段关闭配置
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
------------------------------------------------------------

posted on 2014-07-01 16:31  阿斌1986  阅读(330)  评论(0编辑  收藏  举报

欢迎光临阿斌的博客! QQ:496087321 更多精彩请访问:谢斌个人博客