I am trying to call OPENROWSET command in SQL server 2012 to read data from xls excel file below is my code
SET @sql = 'SELECT * FROM [' + @Query + '$]'
Exec(
'select *
FROM OPENROWSET(
''Microsoft.Jet.OLEDB.4.0''
,''Excel 16.0;Database=' + @FileDirectory + '\'+ @FileName + ';HDR=YES''
,''' + @sql + ''')'
)
after running the command it gives
Msg 7302, Level 16, State 1, Line 1 Cannot create an instance of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".
I tried to call
EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
EXEC sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE;
GO
but also not working . Also both sql and excel are 64 bit
any other solution??