Results 1 to 9 of 9

Thread: BCP Help

  1. #1
    Join Date
    Jan 2004
    Posts
    6

    Red face Unanswered: BCP Help

    I'm tryping to use BCP to transfer some data to a file. In an effort ot learn about it, I'm trying some simple stuff with the pubs database and some examples from BOL. However, none of them are working.

    I'm trying this command:

    bcp "SELECT au_fname, au_lname FROM pubs..authors ORDER BY au_lname" queryout Authors.txt -c -Sservername -Usa -Ppassword

    Of course i'm changing servername, sa, and password to the appropriate stuff..

    I get the following error:

    Server: Msg 170, Level 15, State 1, Line 1
    Line 1: Incorrect syntax near 'queryout'.


    Any ideas why this example from BOL isn't working for me?

    Thanks in advance!

    Mark

  2. #2
    Join Date
    Aug 2003
    Location
    Andover, MA
    Posts
    256
    That looks right. If you are doing this from within SQL (constructing a statement and executing xp_cmdshell, are you sure this is the statement being formed?
    -bpd

  3. #3
    Join Date
    Jan 2004
    Posts
    6
    Originally posted by bpdWork
    That looks right. If you are doing this from within SQL (constructing a statement and executing xp_cmdshell, are you sure this is the statement being formed?
    I'm actually using Query Analyzer and getting that error. Would that make any difference?

  4. #4
    Join Date
    Aug 2003
    Location
    Andover, MA
    Posts
    256
    Ah, yes.

    BCP is a command line utility, not a SQL command. To run it from QueryAnalyser, you need to shell the command to the operating system with xp_cmdshell.

    Try running it froma Command Prompt.

    -b
    -bpd

  5. #5
    Join Date
    Jan 2004
    Posts
    6
    Originally posted by bpdWork
    Ah, yes.

    BCP is a command line utility, not a SQL command. To run it from QueryAnalyser, you need to shell the command to the operating system with xp_cmdshell.

    Try running it froma Command Prompt.

    -b
    Awesome. Thanks so much.. Worked great. I feel like an idiot now.

    Thanks again

  6. #6
    Join Date
    Aug 2003
    Location
    Andover, MA
    Posts
    256
    You mean, you feel smarter now.
    -bpd

  7. #7
    Join Date
    Jan 2004
    Posts
    6
    Originally posted by bpdWork
    You mean, you feel smarter now.
    Something like that. Maybe one day i'll beable to get a job as a DBA.

  8. #8
    Join Date
    Aug 2003
    Location
    Andover, MA
    Posts
    256
    DBA is boring. Programming is where it's at man! (Let the hell-fire begin!)
    -bpd

  9. #9
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    DBA is boring. Programming is where it's at man! (Let the hell-fire begin!)
    Am having a different kinda
    discussion right now.

    BTW ... there is a difference between a support DBA and a development DBA.
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

Posting Permissions

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