Consulting

Results 1 to 2 of 2

Thread: Urgent : How run BCP command using .bat/.vbs file from Excel VBA?

  1. #1

    Urgent : How run BCP command using .bat/.vbs file from Excel VBA?

    Hi Everybody


    Please treat this as an urgent request!

    Does anyone know how to run the BCP command using VBA :-


    bcp ea_network_accrual.dbo.net_meter format nul -f c:\deepak\FormatFileFromScript.fmt -c -Smpfinsd\stage -T


    I can successfully run this on DOS command prompt. I was trying to test this using a .bat or .vbs file to be called using Shell.Run command from within an Excel VBA module, but it doesn't seem to work.

    The above command is to create the format file. This h as already been done. What I actually want to do is to be able to run another BCP command to upload a whole stack of data using the previously created format file in to a SQL Server database table. I want to call the BCP command from within the Excel VBA module.

    BCP obviously from the DOS console and I have been able to run from there successfully - both to create the format and also to upload the data using the previously created format file.


    Any suggestions?



    This is the code that I have :-


    [vba]
    Sub RunBCP()
    Set objShell = CreateObject("Wscript.Shell")
    strBCP = "bcp ea_network_accrual.dbo.net_meter format nul -f c:\deepak\FormatFile_Script.fmt -c -Smpfinsd\stage -T"
    objShell.Run strBCP, 1, True
    End Sub
    [/vba]

    Best Regards



    Deepak

  2. #2
    Has this been solved? I have the same issue and can't seem to find a solution.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •