Excel into SQL Server with Microsoft.ACE.OLEDB.12.0

I’m getting the following error when trying to open an Excel file in SQL Server 2008 r2 64-bit:

Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" 
reported an error. The provider did not give any information about the 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)".

I’m using the following query:

  • Change Owner of Database Diagram in SQL Server 2005
  • SQL Server: Multiple Output Clauses
  • jQuery Autocomplete remote datasource and dynamic rows
  • Full Text Search Auto-Partition Schemes and Functions
  • How can I convert bigint (UNIX timestamp) to datetime in SQL Server?
  • SQL Server: Table-valued Functions vs. Stored Procedures
  • SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0; 
    HDR=NO; IMEX=1; Database=\\filepath\filename.xlsx', 'SELECT * FROM [Sheet1$]')

    The funny thing is that the DBA can run it without issue. I’ve gone through and ran the following queries:

    sp_configure 'Show Advanced Options', 1;
    sp_configure 'Ad Hoc Distributed Queries', 1;
    EXEC sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
    EXEC sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1

    The account that runs it looks like it has sa access. What could be causing this issue?

  • SQL Server - defining an XML type column with UTF-8 encoding
  • Can't access a network share when executing a package from the SSIS Catalog
  • Convert datetime to yyyymmddhhmmss in sql server
  • Create a join that can (include some) or (include all except some) records
  • How do I create a unique constraint that also allows nulls?
  • Retrieve last row inserted with Uniqueidentifier that it is not IDENTITY
  • 3 Solutions collect form web for “Excel into SQL Server with Microsoft.ACE.OLEDB.12.0”

    have you tried (as a test) copying the Excel file onto the SQL Server C:\ drive and executing the query against that path?

    what happens when you go onto the server and open this path in Explorer/run dialog: \filepath\filename.xlsx?

    Are you able to execute this query: exec master..xp_cmdshell ‘dir ‘\filepath\filename.xlsx’?

    This will help you determine if it’s a network rights issue, or whether the account has the permissions to use distributed queries.

    My hunch is that it’s definitely a rights/permission issue, as the DBA can run it.

    As Philip has said…first check the execution of xp_cmdshell. If it is not running due to permission issue then first reconfigure this option by running


    after this run following command to enable linked server permissions for InProcess capabilities for ACE driver :

    USE [master]
    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

    Now run this series of commands :

    sp_configure 'show advanced options', 1
    sp_configure 'Ad Hoc Distributed Queries', 1

    if error encountered then run each command separately. And finally run import all your excel data to SQL server by running the below mentioned command :

    SELECT * INTO TargetTableName FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
                             'Excel 12.0;Database=FilePath\fileName.xlsx;HDR=YES',
                             'SELECT * FROM [sheetName$]')

    Remember that in case of xls you have to use Jet Driver instead of ACE. And also the TargetTableName must not be existing prior to running this query.
    Happy coding 🙂

    SQL Server Management Studio. Type Services.msc in the run command to open the services window.

    Search for SQL Server Service and right click it and select properties.

    In the Log On Tab, select system account/or select your domain ID and Account and password.

    Once it finds your login name press OK.

    Now type your login’s passwords in both the fields.

    Restart the services so that the new changes are applied as shown in figure below.

    Now start SQL Server Management Studio and try to run the query if still not working try a system restart.

    or execute the query.

    USE [master] GO 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

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.