SQL Server: Cannot initialize the data source object of OLE DB provider “Microsoft.ACE.OLEDB.12.0” for linked server “(null)”

折月煮酒 提交于 2019-11-30 12:12:51

Make sure you close the excel spreadsheet and run SSMS as admin.

I found from this blog the two missing steps needed to get it working for me.

1) Check the permissions on the Temp folder

This is needed because the provider uses the temp folder while retrieving the data. The folder can be one of the below based on whether you use a local system account or network domain account.

For network accounts, folder is
:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp

and for local system account its
:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp

Right click on this folder and give it read write access to the account executing the code.

2) Check the MemToLeave memory area allocated

  • Open SQL Server Configuration Manager -> Services -> SQLServer service.
  • Right click and choose properties.
  • Go to advanced tab and append -g512; to startup parameters property and it will resolve the issue.

You can also get it working without needing AllowInProcess if you follow the instructions in this MSDN article. The core instructions being:

To be able to execute linked server queries, also set RPC OUT to true on the linked server properties.

Permissions needed to set up linked server with out-of-process provider:

Verify below settings in DCOMCNFG: Start --> Run –> Dcomcnfg

  1. Component services -->My Computer ---> Properties
    Verify that below options are set in the 'Default Properties' tab:

    • 'Enable Distributed COM on this computer' is checked.
    • Default Authentication = Connect.
    • Default Impersonation Level = Identify or Impersonate.
  2. Component services --> My computer --> DCOM Config --> MSDAINITIALIZE

    • Right click on MSDAINITIALIZE --> Properties -->Security
    • Add the SQL Server service account (if connected to SQL server using SQL login) or windows user account under "Launch and Activation Permissions", "Access permissions" and "Configuration Permissions".
    • Give full rights to these accounts.
  3. Restart the server

Kevin Garnett

I also met this issue and did the steps as yours,finally I met the error as yours. In the end, I use a SuperUser account and use this script as below and the issue has been resolved.

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;HDR=Yes;IMEX=1;Database=C:\Somefile.xlsx',
'SELECT * FROM [Sheet$]')
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!