Hi,
I am trying to perform a select operation on excel file using "OPENDATASOURCE" function. I have enabled "Ad Hoc Distributed Queries" option using sp_configure.
my problem is, when I use following query
SELECT * FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source = C:\Documents and Settings\am35300.IND\Desktop\MyPackTest.xls,Extended Properties=EXCEL 5.0')...[Sheet1$]
it throws an error as bellow... OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned message "Could not find file 'C:\Documents and Settings\am35300.IND\Desktop\MyPackTest.xls,Extended Properties=EXCEL 5.0'.".
however if I remove ExtendedProperties from my query, i.e. if I use following query...
SELECT * FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source = C:\Documents and Settings\am35300.IND\Desktop\MyPackTest.xls')...[Sheet1$]
It gives
OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned message "Unrecognized database format 'C:\Documents and Settings\am35300.IND\Desktop\MyPackTest.xls'.".
Will you please help me to find out what is wrong with my query and why above 2 queries giving 2 different error message??
[MyPackTest is an excel(2003) file located in desktop. C:\Documents and Settings\am35300.IND\Desktop\MyPackTest.xls]
Following is a sample of my excel file...
EmployeeID Title BirthDate MaritalStatus Gender Department
3 Engineering Manager 12/13/1964 M M Engineering
4 Senior Tool Designer 1/23/1965 S M Engineering
9 Design Engineer 10/29/1942 M F Engineering
11 Design Engineer 4/11/1949 M M Engineering
12 Vice President 9/1/1961 S F Engineering
267 Senior Engineer 7/17/1969 S M Engineering
Thanks & Regards, Amit Mishra
Submitted under:
Microsoft SQL Server · TSQL · DBA · ·