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 2000 Forums
 SQL Server Development (2000)
 I dont want to use Field terminator in BCP

Author  Topic 

Clages1
Yak Posting Veteran

69 Posts

Posted - 2006-12-05 : 10:12:04

Hi again
using this query in query analizer works fine
but (always but) BCp puts 09 (tab character) between fields
even i dont use -t parameter.

then i get
123XnameXadress where X is a tab character
i want
123nameadress

how can i fix it? I dont want to use any terminator between field

tks
agains
Clages

Select * into tmparea from (select * from area) T
Exec master..xp_cmdShell 'bcp "Select * from teste.dbo.tmparea" queryout "C:\area.txt" -S Clages1 -U"sa" -P "teste" -c -T'
Drop table tmparea


SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-05 : 10:16:06
Exec master..xp_cmdShell 'bcp "Select col1+col2+col+...+colX from teste.dbo.tmparea" queryout "C:\area.txt" -S Clages1 -U"sa" -P "teste" -c -T'


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Clages1
Yak Posting Veteran

69 Posts

Posted - 2006-12-05 : 10:32:37
ok, But in this case i will have to convert all fields to Char
i will fix one thing and broke other, because i have in this query
a several sort of field (date, Int, char, varchar, etc)
and i need all the field aligned.

is there another solution?

tks

C. lages
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2006-12-05 : 10:36:03
You mean you want fixed length fields rather than delimitted.
I would use a stored procedure to format the data for the bcp.

Have a look at
http://www.simple-talk.com/sql/database-administration/creating-csv-files-using-bcp-and-stored-procedures/

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -