Search code examples
sql-serversql-server-2005bcp

BCP utility:"Copy direction must be either 'in', 'out' or 'format'"


I get below mentioned error when I run BCP command for trusted connection:

Copy direction must be either 'in', 'out' or 'format'.

I tried searching MSDN, where it specifies that servername passed could be incorrect.

The command I am trying is:

bcp %SQL_database%..TABLE1 in \FileSERVER\file.dat -f\fileserver\Formats\file.fmt -eERR.txt -m1000000 -C -T RAW -S%SQL_server%

When I pass a username and password instead of using the -T option, it works. The command is executed from command prompt by passing parameters from command line.


Solution

  • Your -C and -T options are flip-flopped - -C -T RAW instead of -C RAW -T.

    Check the bcp utility's online documentation for confirmation that -C rather than -T should precede RAW.

    Try this instead:

    bcp %SQL_database%..TABLE1 in \FileSERVER\file.dat -f\fileserver\Formats\file.fmt -eERR.txt -m1000000 -C RAW -T -S%SQL_server%
    

    My guess is that you probably misplaced the -T option when switching to a trusted connection (with the -T option) from integrated security (with the -U and -P options).