bcp File without Field Delimiter

I came across to this question last year. Without digging too much, I came up with a T-SQL solution to export everything in one huge column. But it involves a lot data type convert code. The reader came back with the same question again and I tried to play with bcp again and found the solution.

I used the HEX value no space 0x90 or 0x8F as the field delimiter to export the file directly

DECLARE @logtext AS VARCHAR(4000), @cmd AS VARCHAR(4000)
set @logtext = '"select * from PRCARGEAFS2ALGE.EDI_DATA.dbo.EDI_810_READY_TO_EXPORT "'

set @cmd6 = 'BCP  ' + @logtext + ' queryout  "C:\temp\sales1.txt"  -c -t 0x90 -T  -S'+ @@servername
exec master..xp_cmdshell @cmd6
 I provided the concatenate query solution (workaround):





Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s