I\'m getting the following error when trying to open an Excel file in SQL Server 2008 r2 64-bit:
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider \"Mi
As Philip has said...first check the execution of xp_cmdshell. If it is not running due to permission issue then first reconfigure this option by running
SP_CONFIGURE 'XP_CMDSHELL',1
GO
RECONFIGURE
after this run following command to enable linked server permissions for InProcess capabilities for ACE driver :
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
Now run this series of commands :
sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
if error encountered then run each command separately. And finally run import all your excel data to SQL server by running the below mentioned command :
SELECT * INTO TargetTableName FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=FilePath\fileName.xlsx;HDR=YES',
'SELECT * FROM [sheetName$]')
Remember that in case of xls you have to use Jet Driver instead of ACE. And also the TargetTableName must not be existing prior to running this query. Happy coding :)