sql server OpenDataSource查询excel数据

SELECT FROM OpenDataSource( 'Microsoft.ACE.OLEDB.12.0','Data Source="d: est.xlsx";Extended properties=Excel 12.0')...[sheet1$]

1、错误提示:尚未注册 OLE DB 访问接口 "Microsoft.ACE.OLEDB.12.0"。

  回答:去AccessDatabaseEngine.exe下载。然后安装就行了

2、错误提示1:

  -- 启用: 

  exec sp_configure 'show advanced options',1 

  reconfigure 

  exec sp_configure 'Ad Hoc Distributed Queries',1 

  reconfigure 

     --使用完毕后,记得要关闭它,因为这是一个安全隐患

     exec sp_configure 'Ad Hoc Distributed Queries',0

     reconfigure

     exec sp_configure 'show advanced options',0

     reconfigure

2、错误提示2:关于【无法创建链接服务器 "(null)" 的 OLE DB 访问接口 

   开启以下:

--允许在进程中使用ACE.OLEDB.12
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
--允许动态参数
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1

原文地址:https://www.cnblogs.com/yclizq/p/12199153.html