Issue when reading data from excel sheet

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ammoos
    New Member
    • Apr 2007
    • 100

    #1

    Issue when reading data from excel sheet

    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.xx x\upload\Data_S heet.xls'
    EXEC MASTER..XP_CMDS HELL @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='+ @CurrentDateNum ber +''')')


    Please help me

    Ammooss
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Can you access that machine from the SQL Server?

    -- CK

    Comment

    • ammoos
      New Member
      • Apr 2007
      • 100

      #3
      Yes.. I can access that machine from sql server machine

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        How do you access the remote machine?

        -- CK

        Comment

        • ammoos
          New Member
          • Apr 2007
          • 100

          #5
          Sorry..I couldnt understand your question.. I access the remote machine using the IP via the Run

          Comment

          • ck9663
            Recognized Expert Specialist
            • Jun 2007
            • 2878

            #6
            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

            Comment

            • ammoos
              New Member
              • Apr 2007
              • 100

              #7
              CK

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

              Ammooss

              Comment

              • ammoos
                New Member
                • Apr 2007
                • 100

                #8
                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_c mdshell @msg

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

                Ammooss

                Comment

                • ck9663
                  Recognized Expert Specialist
                  • Jun 2007
                  • 2878

                  #9
                  Here, read this first.

                  Good luck!

                  --- CK

                  Comment

                  Working...