BCP problem

  • Hi,

    I tried to have tab (-t) as my column delimeter when bcp out data from table:

    bcp DATABASENAME.dbo.TABLENAME out XXXX.txt -c -t -r\n -S %SqlServer% -T || SET ErrMsg=BCP out of XXXX failed. && Goto :EndErr

    Somehow the -t doesn't work. Could anyone give me the hint? Thanks a million.

    Chris

  • Try -t\t

     


    And then again, I might be wrong ...
    David Webb

  • H David,

    Thanks for the help. I tried:

    bcp DATABASENAME.dbo.TABLENAME out XXXX.txt -c -t\t -r\n -S %SqlServer% -T || SET ErrMsg=BCP out of XXXX failed. && Goto :EndErr

    It still does not work. I tried and failed with several formats. Finally I went back to "basic" format like this:

    bcp DATABASENAME.dbo.TABLENAME out XXXX.txt -c -S %SqlServer% -T || SET ErrMsg=BCP out of XXXX failed. && Goto :EndErr

    I removed both -t and -r/n. Although the fix does not make sense to me, however, it works for some reason. Again thanks for tip.

    Chris

  • Removing both would have caused BCP to use the defaults which are tab and newline.

     

    --------------------
    Colt 45 - the original point and click interface

  • Hi Phill,

    It must have a reason in order to work. So if I understand correctly, it works because -t and -r/n are part of default. But why it didn't work when I spell it out? Thanks for pointing out.

    Chris

  • The switches for BCP have always held some sort of mystical property. I mean there is such a thing as too many options.

     

    --------------------
    Colt 45 - the original point and click interface

  • Hi chris,

    just have at the site . http://doc.ddart.net/mssql/sql70/impt_bcp_36.htm

    But i ask Mr.Phill what type of mystical property did BCP switches have can u pls explain.

    hope this helps u chris.

    from

    sufian

      

  • I fail to see where the provided link has anything to do with field or row field terminators.

    Surely any command with a syntax like,

    bcp {[[database_name.][owner].]{table_name | view_name} | "query"}

        {in | out | queryout | format} data_file

        [-m max_errors] [-f format_file] [-e err_file]

        [-F first_row] [-L last_row] [-b batch_size]

        [-n] [-c] [-w] [-N] [-V (60 | 65 | 70)] [-6]

        [-q] [-C code_page] [-t field_term] [-r row_term]

        [-i input_file] [-o output_file] [-a packet_size]

        [-S server_name[\instance_name]] [-U login_id] [-P password]

        [-T] [-v] [-R] [-k] [-E] [-h "hint [,...n]"]

    takes on a mystical aspect.

     

    --------------------
    Colt 45 - the original point and click interface

Viewing 8 posts - 1 through 7 (of 7 total)

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