Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 BCP Result File

Author  Topic 

pmohans123
Starting Member

5 Posts

Posted - 2009-04-03 : 02:15:01
Hi,

I have two questions

1. I am using the BCP command to export the result into the text file. Generally the file result is in comma separated, but I want the result in space separated. like

S.NO Name City
1 AAAA XXXXX
2 BBBB YYYYY

Please tell me what option I have to use to get the above mentioned format result in the output file.

2. My second question is, in query analyzer I am running some query to get the result in text format, I am getting the result correctly, but the thing is I am seeing lot of space between one column to another, Is there any command to reduce the space between the column in the text result.

I am eagerly waiting the answer/solution for these 2 qns. Thanks in advance.

Bye
PMS

darkdusky
Aged Yak Warrior

591 Posts

Posted - 2009-04-03 : 10:52:41
You can use tab (\t) as a field terminator, e.g.

bcp dbname..tablename out C:\test.txt -c -t \t -r \n -T
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-04-03 : 13:50:01
My second question is, in query analyzer I am running some query to get the result in text format, I am getting the result correctly, but the thing is I am seeing lot of space between one column to another, Is there any command to reduce the space between the column in the text result.

the space appearing between columns depends on length of fields. so if you want to recude space use cast to reduce length to maximum length of value available in select list
Go to Top of Page
   

- Advertisement -