2013-12-13 28 views
8

Sto cercando di eseguire la seguente query:SQL Server: Impossibile inizializzare l'oggetto origine dati del provider OLE DB "Microsoft.ACE.OLEDB.12.0" per il server collegato "(null)"

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 
'Excel 12.0;Database=C:\Somefile.xlsx', 
'SELECT * FROM [Sheet$]') 

Ma ottengo questo errore:

Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)". 

ho provato la seguente:

sp_configure 'show advanced options', 1; 
RECONFIGURE; 
sp_configure 'Ad Hoc Distributed Queries', 1; 
RECONFIGURE; 
GO 

E:

USE [master] 
GO 


EXEC master . dbo. sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'AllowInProcess' , 1 
GO 

EXEC master . dbo. sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'DynamicParameters' , 1 
GO 

Quando vado su 'Server Objects' -> 'Linked Server' -> 'Provider', viene elencato Microsoft.ACE.OLEDB.12.0.

È installato Acess Database Engine x64, tutti i prodotti Office sono a 64 bit e il mio SQL Server è anche a 64 bit.

Se è importante, tutti gli utenti hanno accesso alla cartella Temp nella cartella Utenti.

(Questi sono tutti i suggerimenti che ho trovato nelle risposte simili a questa domanda)

Edit: Utilizzo di SQL Server 2014.

+0

io non sono abbastanza familiarità con questa roba per ricordare i messaggi di errore al largo della parte superiore della mia testa, così, mi dispiace se questo è irrilevante: È perché la cartella di lavoro è aperta quando si esegue vero? –

+0

La cartella di lavoro non è aperta. –

+0

Funziona quando lo si esegue come amministratore di sistema? – Anon

risposta

10

Assicurati di chiudere il foglio di calcolo di Excel ed eseguire SSMS come amministratore.

+1

Running SSMS come amministratore risolto questo !!! – rept

0

Ho anche incontrato questo problema e ho fatto i passi come tuoi, finalmente ho incontrato l'errore come tuo. Alla fine, uso un account SuperUser e uso questo script come sotto e il problema è stato risolto.

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 
'Excel 12.0;HDR=Yes;IMEX=1;Database=C:\Somefile.xlsx', 
'SELECT * FROM [Sheet$]') 
1

ho trovato da this blog i due passaggi mancanti necessari per farlo funzionare per 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.

Si può anche farlo funzionare senza bisogno AllowInProcess se si seguono le istruzioni in this MSDN article. Le istruzioni di base essendo:

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

Problemi correlati