Mssql 跨域查询
有數(shù)據(jù)庫test1和數(shù)據(jù)庫test2。其中test1中有表 table1、table2;test2 中有表 table1。三個表的字段都為為:id、xingming、shijian、shuliang。接下來我們就以上面的條件為例來介紹跨數(shù)據(jù)庫查詢和跨表 查詢的方法。
SELECT *?
? FROM OPENROWSET('sqloledb',?
?'DRIVER={SQL Server};SERVER=127.0.0.1;UID=sa;PWD=ccds',
?test1.dbo.table1)? where xingming='a'
? UNION?? all
SELECT *?
? FROM OPENROWSET('sqloledb',?
?'DRIVER={SQL Server};SERVER=127.0.0.1;UID=sa;PWD=ccds',
?test2.dbo.table1)? where xingming='a'
?
執(zhí)行后,出現(xiàn)報錯:?阻止了對組件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 的訪問,因為此組件已作為此服務(wù)器安全配置的一部分而被關(guān)閉
執(zhí)行如下語句:
?啟用Ad Hoc Distributed Queries:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
??? 使用完成后,關(guān)閉Ad Hoc Distributed Queries:
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
轉(zhuǎn)載于:https://www.cnblogs.com/fer-team/p/5855643.html
總結(jié)
以上是生活随笔為你收集整理的Mssql 跨域查询的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: javascript简单介绍
- 下一篇: js作用域与作用域链