Home All Groups Group Topic Archive Search About

Insert String into text file using bcp

Author
17 Aug 2006 1:53 PM
ntuyen01
Hi All,

I have a string 'ABC 12345 678910 XXXX   '. I want to insert it into
the test.txt file using bcp command. How do I do that.

Thanks for your help.

Author
17 Aug 2006 2:03 PM
Roy Harvey
One way:

bcp "select 'ABC 12345 678910 XXXX   '" queryout test.txt -c -T

Of course the choice of -T or -U -P is up to you, and -S is up to you.

Another approach would be to make that SELECT a view, adding a column
name of course, and BCP out from the view.

Roy Harvey
Beacon Falls, CT

On 17 Aug 2006 06:53:50 -0700, ntuye***@yahoo.com wrote:

Show quote
>Hi All,
>
>I have a string 'ABC 12345 678910 XXXX   '. I want to insert it into
>the test.txt file using bcp command. How do I do that.
>
>Thanks for your help.
Author
17 Aug 2006 2:51 PM
ntuyen01
It works. Thank You.


Roy Harvey wrote:
Show quote
> One way:
>
> bcp "select 'ABC 12345 678910 XXXX   '" queryout test.txt -c -T
>
> Of course the choice of -T or -U -P is up to you, and -S is up to you.
>
> Another approach would be to make that SELECT a view, adding a column
> name of course, and BCP out from the view.
>
> Roy Harvey
> Beacon Falls, CT
>
> On 17 Aug 2006 06:53:50 -0700, ntuye***@yahoo.com wrote:
>
> >Hi All,
> >
> >I have a string 'ABC 12345 678910 XXXX   '. I want to insert it into
> >the test.txt file using bcp command. How do I do that.
> >
> >Thanks for your help.
Author
17 Aug 2006 3:09 PM
Roy Harvey
I'm glad it worked for you.

Of course there really isn't any need to involve BCP in the process at
all.  This seems to do the same job:

echo select ABC 12345 678910 XXXX   >test.txt

Roy

On 17 Aug 2006 07:51:52 -0700, ntuye***@yahoo.com wrote:

Show quote
>It works. Thank You.
>
>
>Roy Harvey wrote:
>> One way:
>>
>> bcp "select 'ABC 12345 678910 XXXX   '" queryout test.txt -c -T
>>
>> Of course the choice of -T or -U -P is up to you, and -S is up to you.
>>
>> Another approach would be to make that SELECT a view, adding a column
>> name of course, and BCP out from the view.
>>
>> Roy Harvey
>> Beacon Falls, CT
>>
>> On 17 Aug 2006 06:53:50 -0700, ntuye***@yahoo.com wrote:
>>
>> >Hi All,
>> >
>> >I have a string 'ABC 12345 678910 XXXX   '. I want to insert it into
>> >the test.txt file using bcp command. How do I do that.
>> >
>> >Thanks for your help.

AddThis Social Bookmark Button