By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,301 Members | 1,999 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,301 IT Pros & Developers. It's quick & easy.

Issue when reading data from excel sheet

ammoos
100+
P: 100
Hi Friends

I am getting the following error when I am trying to read data from an excel sheet using sql script

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.].


If I save the excel file in the database server machine, then it will work fine.. I am getting this error message when I save the excel file in any other machine in the network and trying to read data from that excel sheet

I am using the following code

Select @PowerFileName = '\\xxx.xxx.x.xxx\upload\Data_Sheet.xls'
EXEC MASTER..XP_CMDSHELL @cmd, NO_OUTPUT
set @provider = 'Microsoft.Jet.OLEDB.4.0'
set @ExcelString = 'Excel 5.0;Database=' + @PowerFileName
EXEC ('select * into tbl_BaseLoad from OPENrowset(''' + @provider + ''',''' + @ExcelString + ''',''SELECT * FROM [baseload$] WHERE F3 IS NOT NULL UNION SELECT * FROM [baseload$] WHERE F2='+ @CurrentDateNumber +''')')


Please help me

Ammooss
Jun 26 '09 #1
Share this Question
Share on Google+
8 Replies


ck9663
Expert 2.5K+
P: 2,878
Can you access that machine from the SQL Server?

-- CK
Jun 26 '09 #2

ammoos
100+
P: 100
Yes.. I can access that machine from sql server machine
Jun 29 '09 #3

ck9663
Expert 2.5K+
P: 2,878
How do you access the remote machine?

-- CK
Jun 30 '09 #4

ammoos
100+
P: 100
Sorry..I couldnt understand your question.. I access the remote machine using the IP via the Run
Jun 30 '09 #5

ck9663
Expert 2.5K+
P: 2,878
I mean accessing inside the SQL Server. The RUN command is on the OS level, not inside SQL Server. Have you tried accessing the remote machine from SQL Server via IP?

--- CK
Jun 30 '09 #6

ammoos
100+
P: 100
CK

I am not sure how to access the remote machine from SQL Server via IP.. Can you pls help me?

Ammooss
Jul 1 '09 #7

ammoos
100+
P: 100
CK

I just tried to copy the same excel file from remote machine to the server machine using the following code.. but that time I got the message "Access is denied"

declare @msg varchar(3000)
declare @file varchar(1000)
declare @file1 varchar(1000)

set @file = '\\remote macine IP\folder\Data_Sheet.xls'
set @file1 = '\\server machine IP\folder\Data_Sheet1.xls'

SET @msg = 'copy "' + @file + '" "' + @file1 + '"';

exec master.dbo.xp_cmdshell @msg

but this code works fine if I try to copy a file from one folder in the server machine to another folder

Ammooss
Jul 1 '09 #8

ck9663
Expert 2.5K+
P: 2,878
Here, read this first.

Good luck!

--- CK
Jul 1 '09 #9

Post your reply

Sign in to post your reply or Sign up for a free account.