BCP w/ Queryout

  • I've got a developer running a bcp with the queryout option.  The bcp works fine on the certification server but fails the following error on our development server.

    Query:

    bcp "exec IndexFab.dbo.usp_get_logzilla_report @begin='2004-03-18 00:00:00.000',@end='2004-03-18 23:59:59.997'" queryout "

    test.txt" -U -P -S -w -q

    Error:

    Executed as user:  Copy direction must be either 'in' or 'out'.  Syntax Error in 'queryout'.  usage: bcp [[database_name.]owner.]table_name[:slice_number] {in | out} datafile   [-m maxerrors] [-f formatfile] [-e errfile]   [-F firstrow] [-L lastrow] [-b batchsize]   [-n] [-c] [-t field_terminator] [-r row_terminator]   [-U username] [-P password] [-I interfaces_file] [-S server]   [-a display_charset] [-q datafile_charset] [-z language] [-v]   [-A packet size] [-J client character set]    [-T text or image size] [-E] [-g id_start_value] [-N] [-X]   [-M LabelName LabelValue] [-labeled]   [-K keytab_file] [-R remote_server_principal]   [-V [security_options]] [-Z security_mechanism] [-Q].  Process Exit Code -1.  The step failed.

    Checked the bcp versions and both are the same.

  • I would double check the versions again. In fact I think I would copy the bcp.exe file from the machine it works to a different directory on the dev machine and try it again. Also what version of SQL Server are you using? When I type bcp from the command prompt I get the following...

    usage: bcp {dbtable | query} {in | out | queryout | format} datafile

      [-m maxerrors]            [-f formatfile]          [-e errfile]

      [-F firstrow]             [-L lastrow]             [-b batchsize]

      [-n native type]          [-c character type]      [-w wide character type]

      [-N keep non-text native] [-V file format version] [-q quoted identifier]

      [-C code page specifier]  [-t field terminator]    [-r row terminator]

      [-i inputfile]            [-o outfile]             [-a packetsize]

      [-S server name]          [-U username]            [-P password]

      [-T trusted connection]   [-v version]             [-R regional enable]

      [-k keep null values]     [-E keep identity values]

      [-h "load hints"]

    Please take note that I'm using SQL2k. Also note that -T on mine is for a trusted connection where as what you posted is "text or image size".




    Gary Johnson
    Microsoft Natural Language Group
    DBA, Sr. DB Engineer

    This posting is provided "AS IS" with no warranties, and confers no rights. The opinions expressed in this post are my own and may not reflect that of my employer.

  • Found the problem was due to the sybase client being loaded.  The query was using that copy of bcp.  Fixed the problem by having the developer putting an explicit path.

     

    Thanks for the reply

  • I'm having the same type of problem. I'm running SQL Server 2K on an NT machine. When I try to bcp queryout I get the following error.

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

    Syntax Error in 'queryout'.

    usage: bcp [[database_name.]owner.]table_name[:slice_number] {in | out} datafile

    [-m maxerrors] [-f formatfile] [-e errfile]

    [-F firstrow] [-L lastrow] [-b batchsize]

    [-n] [-c] [-t field_terminator] [-r row_terminator]

    [-U username] [-P password] [-I interfaces_file] [-S server]

    [-a display_charset] [-q datafile_charset] [-z language] [-v]

    [-A packet size] [-J client character set]

    [-T text or image size] [-E] [-g id_start_value] [-N] [-X]

    [-M LabelName LabelValue] [-labeled]

    [-K keytab_file] [-R remote_server_principal]

    [-V [security_options]] [-Z security_mechanism] [-Q]

    NULL

    This is the bcp command I am using:

    bcp "SELECT ISNULL(title_id,'Tot'), COUNT(*) as num_recs FROM pubs.dbo.titles GROUP BY title_id WITH ROLLUP" queryout " D:\testLoad_title_id_Freq.txt" -P -c

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

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