The OLE DB provider “Microsoft.ACE.OLEDB.12.0” for linked server “(null)”

后端 未结 19 1929
灰色年华
灰色年华 2020-12-02 17:27

I\'m trying to run the following statement but am receiving the error messages just below. I have researched answers to no end and none have worked for me. I\'m running Of

19条回答
  •  天涯浪人
    2020-12-02 17:55

    Here is specifically what worked for me only when the Excel file being queried was not open and when running the SQL Server Service as me [as a user that has access to the file system]. I see pieces of my answer already given elsewhere, so I apologize for any redundancy, but for the sake of a more succinct answer:

    USE [master]
    GO
    
    EXEC sp_configure 'Show Advanced Options', 1
    RECONFIGURE
    GO
    
    EXEC sp_configure 'Ad Hoc Distributed Queries', 1
    RECONFIGURE
    GO
    
    EXEC sp_MSSet_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
    GO
    
    EXEC sp_MSSet_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1
    GO
    
    
    SELECT * 
    FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
                    'Excel 12.0;Database=C:\MyExcelFile.xlsx',
                    'SELECT * FROM [MyExcelSheetName$]')
    

提交回复
热议问题