SQL SERVER – OLE DB Provider ‘Microsoft.ACE.OLEDB.12.0’ for Linked Server ‘(null)’ Returned Message ‘Unspecified Error’

OLEDBThere are many situations where you have to create a linked server to Microsoft Excel and read data from there. While doing that, I encountered an error and in this blog, we would discuss how to fix OLE DB provider ‘Microsoft.ACE.OLEDB.12.0’ for linked server ‘(null)’ returned message ‘Unspecified error’

Below query can read data from excel in a shared location.

SELECT * FROM OPENROWSET(
'Microsoft.ACE.OLEDB.12.0'
,'Excel 12.0;Database=\\\\FileServer\\ExcelShare\\HRMSDATA.xlsx;HDR=YES;IMEX=1'
,'SELECT * FROM [EMPMASTER$]')

This was failing with error:

OLE DB provider ‘Microsoft.ACE.OLEDB.12.0’ for linked server ‘(null)’ returned message ‘Unspecified error’.
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider ‘Microsoft.ACE.OLEDB.12.0’ for linked server ‘(null)’.

SOLUTION/WORKAROUND – OLEDB

Based on my search on the internet, we were not seeing DisallowAdHocAccess registry key under.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL14.MSSQLSERVER\Providers\Microsoft.ACE.OLEDB.12.0

We then executed below command and key got created automatically.

USE [master]
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DisallowAdHocAccess', 0
GO

After this, we were able to read data from excel without any error.

If you find some other solution, please share via comments.

Here are a few other blog post related to the same subject:

Connect with Twitter.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

Excel, Linked Server, SQL Error Messages, SQL Scripts, SQL Server
Previous Post
SQL SERVER – Huge Size of SSISDB – Catalog Database SSISDB Cleanup Script
Next Post
SQL SERVER – 5061: FIX Error: ALTER DATABASE failed because a lock could not be placed on database ‘Database Name’. Try again later.

Related Posts

3 Comments. Leave new

  • am getting an error as The system cannot find the file specified.

    Reply
  • Getting same error. The system cannot find the file specified.

    Reply
  • You will receive the error RegDeleteValue() returned error 2, ‘The system cannot find the file specified.’
    Msg 22001, Level 1, State 1 because that registry entry does not exist, so cannot be deleted by the RegDeleteValue() call. If it was there, the call would succeed and the entry would be deleted, which is what setting it to 0 does.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.