简体   繁体   中英

Sql Server 2000 openrowset issue

I'm attempting to query and Excel spread sheet on a network share, using the openrowset function with no success. I get the following error:

SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
    'Excel 8.0;DATABASE=\\server\Xdrive:\Spreadsheet.xls',
    'Select * from [Sheet1$]')

Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. The provider did not give any information about the error.
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0' IDBInitialize::Initialize returned 0x80004005: The provider did not give any information about the error.].

I have searched the site and have tried different syntax with no success. I have read that the account may not have access to the network share. What account does this process run under?

0x80004005 very much looks like Access Denied.

You can look in the services.msc what account the SQL Server runs under. A local account will not work outside of the local machine, a Domain account is the better choice if you want to access resources on the network.

An exception is the NetworkService account (available on Windows 2003 and higher). It is a local account that can access the network, it acts as the machine account ( DomainName\\MachineName$ ) in this case. I would recommend a dedicated domain account nevertheless.

I would use network share but not mapped drives since I always thought that they are creating sessions per each user.

It would not cause access error but you probably should specify that the first row of sheet be not skipped by reading headers:

  • SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
    'Excel 8.0;DATABASE=\\server\\ Xdrive: \\Spreadsheet.xls ;HDR=NO ',
    'Select * from [Sheet1$]')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM