dbTalk Databases Forums  

How to avoid BCP from adding BOM at the beginning of output file?

microsoft.public.sqlserver.tools microsoft.public.sqlserver.tools


Discuss How to avoid BCP from adding BOM at the beginning of output file? in the microsoft.public.sqlserver.tools forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Deniz
 
Posts: n/a

Default How to avoid BCP from adding BOM at the beginning of output file? - 01-27-2010 , 04:27 PM






Hello,

I use SQL 2000 on Windows 2003, and I have a scheduled job in my SQL
Agent that runs this:

declare @cmd varchar(2048)

SET @cmd = 'bcp "EXEC sp_select_import" queryout import.txt -c -T'

EXEC master..xp_cmdshell @cmd

This creates my tab delimited file 'import.txt'. However importing
this file into some 3rd party application doesn't work because of the
Byte Order Mark at the beginning of the file. My current workaround is
to resave the file in Excel. Is there any way to eliminate the BOM
while generating the file?

Thanks in advance,

Deniz

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: How to avoid BCP from adding BOM at the beginning of output file? - 01-27-2010 , 04:55 PM






Deniz (deniz.turkmen (AT) gmail (DOT) com) writes:
Quote:
I use SQL 2000 on Windows 2003, and I have a scheduled job in my SQL
Agent that runs this:

declare @cmd varchar(2048)

SET @cmd = 'bcp "EXEC sp_select_import" queryout import.txt -c -T'

EXEC master..xp_cmdshell @cmd

This creates my tab delimited file 'import.txt'. However importing
this file into some 3rd party application doesn't work because of the
Byte Order Mark at the beginning of the file. My current workaround is
to resave the file in Excel. Is there any way to eliminate the BOM
while generating the file?
Since you use -c which is ANSI character output, I would not expect
this to produce any BOM at all. Does the result set you produce include
any nvarchar columns? Maybe BCP is smart to construct a Unicode file
in this case?

Anyway, I think you use a format file to specify the format, there
should be no BOM, but I have not tested this.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
  #3  
Old   
Deniz
 
Posts: n/a

Default Re: How to avoid BCP from adding BOM at the beginning of output file? - 01-27-2010 , 06:18 PM



On Jan 27, 2:55*pm, Erland Sommarskog <esq... (AT) sommarskog (DOT) se> wrote:
Quote:
Deniz (deniz.turk... (AT) gmail (DOT) com) writes:
I use SQL 2000 on Windows 2003, and I have a scheduled job in my SQL
Agent that runs this:

declare @cmd varchar(2048)

SET @cmd = 'bcp "EXEC sp_select_import" queryout import.txt -c -T'

EXEC master..xp_cmdshell @cmd

This creates my tab delimited file 'import.txt'. However importing
this file into some 3rd party application doesn't work because of the
Byte Order Mark at the beginning of the file. My current workaround is
to resave the file in Excel. Is there any way to eliminate the BOM
while generating the file?

Since you use -c which is ANSI character output, I would not expect
this to produce any BOM at all. Does the result set you produce include
any nvarchar columns? Maybe BCP is smart to construct a Unicode file
in this case?

Anyway, I think you use a format file to specify the format, there
should be no BOM, but I have not tested this.

--
Erland Sommarskog, SQL Server MVP, esq... (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008:http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005:http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000:http://www.microsoft.com/sql/prodinf...ons/books.mspx
No, there are no nvarchar fields. I will give format file a try.
Thanks.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.