Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to read network excel file using openrowset

Author  Topic 

hariharans87
Starting Member

6 Posts

Posted - 2011-07-25 : 08:07:55
Query1:
SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=F:\Test.xls',
'SELECT * FROM [Sheet1$]')

Query2:
SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=\\user11\Test\Test.xls;HDR=YES',
'SELECT * FROM [Sheet1$]')

Please explain how to user Query2.

Thanks,
Hari

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-07-25 : 08:38:46
You need to specify the folder name

SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=\\user11\F\Test\Test.xls;HDR=YES',
'SELECT * FROM [Sheet1$]')

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

hariharans87
Starting Member

6 Posts

Posted - 2011-07-25 : 08:58:57
quote:
Originally posted by madhivanan

You need to specify the folder name

SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=\\user11\F\Test\Test.xls;HDR=YES',
'SELECT * FROM [Sheet1$]')

Madhivanan

Failing to plan is Planning to fail


I have given the correct path surely because i tested.
The error is:
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" reported an error. The provider did not give any information about the 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)".
Go to Top of Page
   

- Advertisement -