Problem using bcp

  • I am attempting to import data from a text file customtextout.txt (data in file is separated by a comma), but not having much luck. I freely admit I have no idea what I am doing, adapting code I have found on-line. I get the following error:

    Copy direction must be either in, out or format

    My ultimate goal is to turn this into a batch file that I can run with Task Scheduler.

    bcp Pats Weather.dbo. TestTable "in C:\wdisplay\webfiles\customtextout7.txt -c –t, -S localhost\PSIMONDS\SQLEXPRESS -T

  • It seems that you have some things that don't belong there.

    bcp Weather.dbo.TestTable in C:\wdisplay\webfiles\customtextout7.txt -c -S localhost\PSIMONDS\SQLEXPRESS -T

    Read more about bcp in here:

    http://msdn.microsoft.com/en-us/library/ms162802.aspx

    http://www.sqlservercentral.com/articles/BCP+(Bulk+Copy+Program)/105867/

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • this looks wrong.

    it should be either localhost\instance or machinename\instance

    so i'd expect some of these to be right:

    -S localhost\SQLEXPRESS

    -S .\SQLEXPRESS

    -S PSIMONDS\SQLEXPRESS (asuming your machine is named PSIMONDS!)

    -S 127.0.0.1\SQLEXPRESS

    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!

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

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