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