通過使用openrowset來讀取excel

2021-05-22 17:31:36 字數 612 閱讀 9503

通過使用openrowset來讀取excel

--開啟許可權

exec sp_configure

'show advanced options',1

reconfigure

exec sp_configure

'ad hoc distributed queries',1

reconfigure

--查詢excel資訊

select * from openrowset( 'microsoft.jet.oledb.4.0','excel 8.0;hdr=yes;user id=admin;password=;imex=1;database=d:/test.xls' ,'select * from [sheet1$]')

--讀取excel資料插入到sqlserver表中

insert into table_name

select * from openrowset( 'microsoft.jet.oledb.4.0','excel 8.0;hdr=yes;user id=admin;password=;imex=1;database=d:/test.xls' ,'select * from [sheet1$]')

使用OpenRowSet操作Excel

有兩種介面可供選擇 microsoft.jet.oledb.4.0 以下簡稱 jet 引擎 和microsoft.ace.oledb.12.0 以下簡稱 ace 引擎 jet 引擎大家都很熟悉,可以訪問 office 97 2003,但不能訪問 office 2007。ace 引擎是隨 office...

使用OpenRowSet操作Excel

有兩種介面可供選擇 microsoft.jet.oledb.4.0 以下簡稱 jet 引擎 和microsoft.ace.oledb.12.0 以下簡稱 ace 引擎 jet 引擎大家都很熟悉,可以訪問 office 97 2003,但不能訪問 office 2007。ace 引擎是隨 office...

使用OpenRowSet操作Excel

有兩種介面可供選擇 microsoft.jet.oledb.4.0 以下簡稱 jet 引擎 和microsoft.ace.oledb.12.0 以下簡稱 ace 引擎 jet 引擎大家都很熟悉,可以訪問 office 97 2003,但不能訪問 office 2007。ace 引擎是隨 office...