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

SQL
3 Comments

SQL SERVER - OLE DB Provider 'Microsoft.ACE.OLEDB.12.0' for Linked Server '(null)' Returned Message 'Unspecified Error' errorole-500x479 There 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.

Reference: Pinal Dave (https://blog.sqlauthority.com)

Excel, Linked Server, SQL Error Messages, SQL Scripts, SQL Server
Previous Post
SQL SERVER – Get List of the Logical and Physical Name of the Files in the Entire Database
Next Post
Data Privacy – Are Your Database Processes Fully Compliant?

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