64位環境中使用SQL查詢excel的方式解決

2021-05-25 06:29:28 字數 1654 閱讀 7225

--64位環境中使用sql查詢excel的方式

環境:os:windows

server 2008 r2 enterprise

mssql:

microsoftsql server 2008 r2 (rtm) - 10.50.1600.1 (x64)  (build 7601: service pack 1)

查詢access的方式,請移步:在mssql中對access檔案操作方式彙總

因為sql2005預設是沒有開啟'ad hoc distributed queries' 元件,開啟方法如下

--使用sa登入資料庫

exec sp_configure 'show advanced options', 1  --更改配置

go reconfigure       --安裝

go exec sp_configure 'ad hoc distributed queries', 1

go reconfigure

go--查詢配置值

select value,value_in_use,name

from sys.configurations

where name ='ad hoc distributed queries'

一、案情:執行microsoft.jet.oledb.4.0查詢excel報錯。

**:select *

from opendatasource('microsoft.jet.oledb.4.0',  

'data source=c:/book1.xlsx;

user id=admin;password=;extended properties=excel 8.0;')...a$ 

--result: /*

訊息7308,級別16,狀態1,第1 行

因為ole db 訪問介面'microsoft.jet.oledb.4.0' 配置為在單執行緒單元模式下執行,所以該訪問介面無法用於分布式查詢。 */

二、緣由:

--預設情況下,microsoft ole db provider for jet 和jet odbc 驅動程式只能在為環境下執行,無法執行在位模式下。

三、處理:

英文位址

中文位址

注意:如果本機已安裝位的office元件,則要先進行解除安裝,再安裝位的made2010。

在安裝accessdatabaseengine_x64

.exe之後更換microsoft

.ace

.oledb驅動查詢:

**:

select @@version,*

from opendatasource('microsoft.ace.oledb.12.0',  

'data source=c:/book1.xlsx;

user id=admin;password=;extended properties=excel 12.0;')...a$ 

--結果如圖所示:

——>總結:找對問題是關鍵,比如這裡的made2010驅動。

posted by: select left('claro',2) @15:00:33

lable: sql,windows

windows 64位環境下php執行環境部署配置

2 解壓安裝包,我的解壓到d tools php5.6 3 配置php.ini 在解壓的目錄中,找到php.ini檔案,如果沒有這個檔案,可以複製目錄中的php.ini development 該檔名為php.ini a.設定時區 date.timezone prc b.設定編碼 default c...

windows 64位環境下php執行環境部署配置

2 解壓安裝包,我的解壓到d tools php5.6 3 配置php.ini 在解壓的目錄中,找到php.ini檔案,如果沒有這個檔案,可以複製目錄中的php.ini development 該檔名為php.ini a.設定時區 date.timezone prc b.設定編碼 default c...

64位環境下SSIS連線oracle問題收集

1,title connection manager test connection failed because of an error in initializing provider.error while trying to retrieve text for error ora 12154...