SQL Server将数据库链接到Excel文件,没有显示任何表格,但没有错误。

huangapple go评论68阅读模式
英文:

SQL Server Link Database to Excel File not showing any tables but with no errors

问题

I am using SQL Server 2017 on Windows 2022 and am creating a linked server to an excel table to import data.

I have ensured that I have installed the Microsoft.ACE.OLEDB.12.0 driver.

I have used the following script to add the linked server:

EXEC sp_addlinkedserver
     @server = N'test1',
     @srvproduct = N'Excel',
     @provider = N'Microsoft.ACE.OLEDB.12.0',
     @datasrc = N'C:\mytest\testexcel.xlsx',
     @provstr = N'Excel 12.0;IMEX=1;HDR=YES;';

I run the script: no errors.
I right click on the newly created linked server and test the connection: It connects OK.

However, there is no Sheet1$ as expected. I am left scratching my head as I am not getting any errors.

英文:

I am using SQL Server 2017 on Windows 2022 and am creating a linked server to an excel table to import data.

I have ensured that I have installed the Microsoft.ACE.OLEDB.12.0 driver:

SQL Server将数据库链接到Excel文件,没有显示任何表格,但没有错误。

I have used the following script to add the linked server:

EXEC sp_addlinkedserver
     @server = N'test1',
     @srvproduct = N'Excel',
     @provider = N'Microsoft.ACE.OLEDB.12.0',
     @datasrc = N'C:\mytest\testexcel.xlsx',
     @provstr = N'Excel 12.0;IMEX=1;HDR=YES;';

I run the script: no errors.
I right click on the newly created linked server and test the connection: It connects OK

SQL Server将数据库链接到Excel文件,没有显示任何表格,但没有错误。

However, there is no Sheet1$ as expected.

I am left scratching my head as I am not getting any errors.

答案1

得分: 2

找到了问题:

虽然我已经设置了许多 SQL Server 实例并多次安装了 Microsoft.ACE.OLEDB.12.0 驱动程序,但我不记得曾经需要修改驱动程序的属性才能让它正常工作。

我不确定默认设置是否有变化,但我的调查让我找到了一台旧服务器,以比较驱动程序的设置。我发现在我们的旧服务器上,“允许进程内”驱动程序选项被选中。

我转到我们的新服务器,发现它没有被选中,所以我执行了以下操作:

右键单击 Microsoft.ACE.OLEDB.12.0 驱动程序

然后确保选中“允许进程内”。

这似乎解决了问题。

但是,我搜索了一些关于“允许进程内”设置的用法,但找不到文档,所以即使它有效,我也不知道为什么。

英文:

Found the issue:

Although having setup many instances of SQL server and installed the Microsoft.ACE.OLEDB.12.0 driver many times I do not recall having to modify the properties of the driver to allow it to work.

I am not sure if the defaults have changed but by investigations led me to an old server to compare the driver settings and I found that on our old server the "Allow inprocess" driver option was checked.

I went to our new server and found it was not checked, so did the following:

Right clicked on the Microsoft.ACE.OLEDB.12.0 driver

SQL Server将数据库链接到Excel文件,没有显示任何表格,但没有错误。

Then ensure the Allow inprocess is checked.

SQL Server将数据库链接到Excel文件,没有显示任何表格,但没有错误。

This seems to have cured the issue.

However, I did some searches for the usage of the Allow inprocess setting but can find no documentation, so even though it works, I don't know why.

huangapple
  • 本文由 发表于 2023年5月21日 22:00:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76300275.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定