1 SQL SERVER 中 查看有无访问接口,以下其中任何一个即可. 没有则下载 Microsoft Access Database Engine 2016 Redistributable (Microsoft Access 2016 数据库引擎可再发行程序包) 安装
2 开启 Ad Hoc Distributed Queries
启用Ad Hoc Distributed Queries: exec sp_configure 'show advanced options',1 reconfigure exec sp_configure 'Ad Hoc Distributed Queries',1 reconfigure 关闭Ad Hoc Distributed Queries: exec sp_configure 'Ad Hoc Distributed Queries',0 reconfigure exec sp_configure 'show advanced options',0 reconfigure
3 设置 访问接口 属性
4 查询,注意 sheet名称后加上$符号.
--> ACE 引擎访问 Excel 2007 select * from OpenRowSet('Microsoft.ACE.OLEDB.16.0', 'Excel 12.0;HDR=Yes;IMEX=1;Database=D:/2007.xlsx', 'select * from [Sheet1$]') select * from OpenRowSet('Microsoft.ACE.OLEDB.16.0', 'Excel 12.0;HDR=Yes;IMEX=1;Database=D:/2007.xlsx', [Sheet1$]) select * from OpenDataSource('Microsoft.ACE.OLEDB.16.0', 'Excel 12.0;HDR=Yes;IMEX=1;Database=D:/2007.xlsx')...[Sheet1$] select * from OpenDataSource('Microsoft.ACE.OLEDB.16.0', 'Data Source=D:/2007.xlsx;Extended Properties="Excel 12.0;HDR=Yes;IMEX=1"')...[Sheet1$]
5