Solved

how to specify delimiter with bcp commad

Posted on 2006-07-20
6
783 Views
Last Modified: 2008-01-09
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
Comment
Question by:riteinfotech
6 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
Comment Utility
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
 
LVL 25

Expert Comment

by:Mr_Peerapol
Comment Utility
you can use -t to specify the feild delimiter
0
 
LVL 6

Expert Comment

by:Devil666
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:riteinfotech
Comment Utility
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
 
LVL 6

Expert Comment

by:Devil666
Comment Utility
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
 
LVL 25

Accepted Solution

by:
Mr_Peerapol earned 125 total points
Comment Utility
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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how the fundamental information of how to create a table.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now