Create TAB delimited file using BCP cmd line

  • Hello,

    I am trying to export data from our staging environment to a .txt file on my local machine. I am using CMD Prompt for this. When I execute the cmd below, I get the error...

    "The system cannot find the file specified"

    Any help would be greatly appreciated!

    sqlcmd -S STAGE -d DB -E -Q ""select * from TABLE where cast(time as date) between '2016-11-01' AND '2016-11-30'"" -o ""c:\MyData.txt"" -h-1 -s""<TAB>"" -w 700

    The are no problems, only solutions. --John Lennon

  • Lord Slaagh (1/3/2017)


    Hello,

    I am trying to export data from our staging environment to a .txt file on my local machine. I am using CMD Prompt for this. When I execute the cmd below, I get the error...

    "The system cannot find the file specified"

    Any help would be greatly appreciated!

    sqlcmd -S STAGE -d DB -E -Q ""select * from TABLE where cast(time as date) between '2016-11-01' AND '2016-11-30'"" -o ""c:\MyData.txt"" -h-1 -s""<TAB>"" -w 700

    the root ofd the c drive is often locked down from being touched by most accounts, try putting it in a c:\temp or c:\data sub folder instead

    if you connect tot eh server, paths on the server refer to the SERVER, not your local C:\drive, so you need a UNC path to get to your machine:

    \\LordSlaagh\c$\SharedFolder\MyData.txt

    that UNC requirement means the service account running on the server has to be a domain account, and have permissions to your machine too...you might still hit a permissions issue with error 5

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks Lowell.

    Is this supposed to be a shared drive? Can it work without? My companies security is locked down, unfortunately.

    The are no problems, only solutions. --John Lennon

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply