BCP to pipe delimited format

  • Server 2008:ABC

    Database:DEF

    Stored proc:up_CheckProc";1 'ZZZ', 1, 0, 1, 1, '2020-04-01 00:00:00.000', '2040-09-30 23:59:29.000', '', '', '', '', '', '', '', '', '', '', '

    Output should be to E drive:E:\output.txt in pipe delimited format

    I keep getting this error message : Copy direction must be either 'in', 'out' or 'format'.

    How I execute this from command line prompt

  • you didn't show your bcp commnad at all.

    in theory, it will look something like this, assuming calling from xp_cmdshell:

    EXECUTE master.dbo.xp_cmdshell 'bcp "EXEC DatabaseName.dbo.up_CheckProc";1 ''ZZZ'', 1, 0, 1, 1, ''2020-04-01 00:00:00.000'', ''2040-09-30 23:59:29.000'', '''', '''', '''', '''', '''', '''', '''', '''', '''', '''', '''' " queryout E:\Output.txt -c -T'

    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!

  • for the pipe delimited row terminator, you need to add -t"|" to the command ; see bcp /? from a command prompt for all the options.

    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!

  • To use a pipe delimiter between each field, use the -t "|" option. -r is the row delimiter

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

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