Wednesday, April 15, 2020

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 reported an unexpected catastrophic failure. 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)".

How to open Excel from SQL
  • Install Access 2010 components
  • Run these scripts
sp_configure 'show advanced options', 1; RECONFIGURE; GO
sp_configure 'Ad Hoc Distributed Queries', 1; RECONFIGURE; GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.15.0', N'AllowInProcess', 1 GO EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.15.0', N'DynamicParameters', 1 GO

  • Restart entire machine
  • Now this code should work
Select * FROM OPENROWSET ( 'Microsoft.ACE.OLEDB.12.0',
     'Excel 12.0; Database=C:\Budget\budget.xlsx;HDR=Yes', 'Select * from [sheet1$]' ) 

    No comments:

    Post a Comment