mysql 跨库插入_sql 跨库和域插入数据库
sql 跨庫和域插入數(shù)據(jù)庫 ; SELECT * INTO [order] FROM OPENROWSET ( 'SQLOLEDB ', '域名'; '用戶名'; '密碼',數(shù)據(jù)庫名稱.表名) 直接執(zhí)行會報以下錯誤 SQL Server 阻止了對組件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的訪
sql 跨庫和域插入數(shù)據(jù)庫 ;
SELECT * INTO [order] FROM
OPENROWSET
( 'SQLOLEDB ', '域名'; '用戶名'; '密碼',數(shù)據(jù)庫名稱.表名)
直接執(zhí)行會報以下錯誤
SQL Server 阻止了對組件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的訪問,因為此組件已作為此服務(wù)器安全配置的一部分而被關(guān)閉。系統(tǒng)管理員可以通過使用 sp_configure 啟用 'Ad Hoc Distributed Queries'。有關(guān)啟用 'Ad Hoc Distributed Queries' 的詳細信息,請參閱 SQL Server 聯(lián)機叢書中的 "外圍應(yīng)用配置器"。
解決方法
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
SELECT * INTO [order] FROM
OPENROWSET
( 'SQLOLEDB ', '域名'; '用戶名'; '密碼',數(shù)據(jù)庫名稱.表名)
執(zhí)行完后
在執(zhí)行
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
報錯的原因:
在從遠程服務(wù)器復(fù)制數(shù)據(jù)到本地時出現(xiàn)“SQL Server 阻止了對組件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的訪問,因為此組件已作為此服務(wù)器安全配置的一部分而被關(guān)閉。系統(tǒng)管理員可以通過使用 sp_configure 啟用 'Ad Hoc Distributed Queries'。有關(guān)啟用 'Ad Hoc Distributed Queries' 的詳細信息 ”錯誤,因此網(wǎng)上搜索,發(fā)現(xiàn)以下解決方法:
啟用Ad Hoc Distributed Queries:
[sql] view plaincopyprint?
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
使用完成后,關(guān)閉Ad Hoc Distributed Queries:
[sql]
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
本人驗證成功:
后查詢SQL聯(lián)機叢書,MSDN官方為下以內(nèi)容:
默認情況下,SQL Server并不允許專案分布式查詢使用OPENROWSET和OPENDATASOURCE。 When this option is set to 1, SQL Server allows ad hoc access.當(dāng)這個選項被設(shè)置為1,SQL Server允許即席訪問。 When this option is not set or is set to 0, SQL Server does not allow ad hoc access.當(dāng)此選項未設(shè)置或設(shè)置為0,SQL Server不允許即席訪問。
Ad hoc distributed queries use the OPENROWSET and OPENDATASOURCE functions to connect to remote data sources that use OLE DB.特設(shè)分布式查詢使用OPENROWSET和OPENDATASOURCE函數(shù)連接到遠程數(shù)據(jù)源,使用OLE DB。 OPENROWSET and OPENDATASOURCE should be used only to reference OLE DB data sources that are accessed infrequently. OPENROWSET和OPENDATASOURCE應(yīng)該只用于引用OLE DB數(shù)據(jù)源很少訪問。 For any data sources that will be accessed more than several times, define a linked server.將會比多次訪問的任何數(shù)據(jù)源,定義鏈接服務(wù)器。
Security Note 安全注意事項
Enabling the use of ad hoc names means that any authenticated login to SQL Server can access the provider.啟用使用的專案名稱,意味著任何身份驗證登錄到SQL Server可以訪問的供應(yīng)商。 SQL Server administrators should enable this feature for providers that are safe to be accessed by any local login. SQL Server管理員應(yīng)該啟用此功能為供應(yīng)商,安全,可以由任何本地登錄訪問。 For more information, see the DisallowAdhocAccess option in Accessing External Data .欲了解更多信息,請參閱在訪問外部數(shù)據(jù) 的DisallowAdhocAccess選項
特此MARK!!!
本文原創(chuàng)發(fā)布php中文網(wǎng),轉(zhuǎn)載請注明出處,感謝您的尊重!
總結(jié)
以上是生活随笔為你收集整理的mysql 跨库插入_sql 跨库和域插入数据库的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: opencv将图像处理之后显示在labe
- 下一篇: mysql 1033_mysql报错10