0

I am trying to read the data from the excel file through the SQL Server 2008.

SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
      'Excel 8.0;Database=C:\Hierarchy.xlsx',
      'SELECT * FROM [Group$]')

Its giving me a weird error:

OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned message "Unspecified error".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)". 

Excel sheet format is correct, path is correct. don't know why its giving me an error.

0

2 Answers 2

1

I found this solution:

I save the existing file in backward compatibility and then fire this one:

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 
'Excel 12.0;HDR=NO;Database=D:\Hierarchy.xls;', 
[Group$])

Don't know why it works and others not, may someone have a good idea about this.

Sign up to request clarification or add additional context in comments.

Comments

0

Try using ACE OleDB and excel version 12.0

Example:

SELECT * FROM 
OPENROWSET
(           

        'Microsoft.ACE.OLEDB.12.0',
        'Data Source=C:\Hierarchy.xlsx;Extended Properties="Excel 12.0;HDR=YES"', 
        'SELECT * FROM [Group$]'
)

5 Comments

Gives following error: OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Could not find installable ISAM.". 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)".
Try installing the ACE provider from this URL
Note that this answer is a good one if you're Excel version is 2007 or later. If it's 2003 or earlier than you want to use the Jet connection, as in your original post.
The installable ISAM error is because it should be Extended Properties="Excel 12.0 Xml;HDR=YES"'
It is excel 2010 version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.