• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 806
  • Last Modified:

how to specify delimiter with bcp commad

i want to  create a text file from a table without/with delimeter with specified spaces that i can provide as parameter in bcp command

like

ramdev|sharma      // pipe delimeted
and

ramdev  sharma      // 2 spaces

and i dont want tabs

ramdev (tab space) sharma

thanks


0
riteinfotech
Asked:
riteinfotech
1 Solution
 
LowfatspreadCommented:
you can use the file terminator certainly to creat a pipe delimited output...

bcp .... -t!

i'd suggest using the format file options to attempt to get a double space delimiter...
(see Books on line ....)

hth
rushed

it may help to state you sql version/edition
0
 
Mr_PeerapolCommented:
you can use -t to specify the feild delimiter
0
 
Devil666Commented:
hi there,

try the following, it is using a trusted connection

bcp "[Dbname]..[TableName]" OUT "[FilePath\FileName.DAT]" -t "[Delimeter]" -c -S"[ServerName]" -T



hth
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
riteinfotechAuthor Commented:
if i want to specify different spaces for every field than what should be exact bcp cpmmand

like i have 6 fields in a table and i want text file like
   1                       2                          3                   4                  5                     6  
ramdev[2 space]sharma[10 space]manager[6 space]26[4 space]25000[10 space]1980

and all teh data from table should be copied in same format,in this case what would the exact bcp command
with systax .
please help
0
 
Devil666Commented:
you could just use a SQL query in your bcp command to do that,

so instead of using a table name, put your query into a view, and then execute the view
0
 
Mr_PeerapolCommented:
Why don't you just use queryout option instead?
Then, specify:

SELECT field1+"   "+field2+"             "+field3 FROM your_table

So you can put whatever valid string as your field delimiter.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now