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

Asked By Deniz
27-Jan-10 08:24 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 does not 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
SQL Server
(1)
Excel
(1)
Nvarchar
(1)
Declare
(1)
Varchar
(1)
Windows
(1)
Deniz.turkmen
(1)
Queryout
(1)
  Erland Sommarskog replied to Deniz
27-Jan-10 08:24 PM
Deniz (deniz.turkmen@gmail.com) writes:

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@sommarskog.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/prodinfo/previousversions/books.mspx
  Deniz replied to Erland Sommarskog
27-Jan-10 08:24 PM
x

No, there are no nvarchar fields. I will give format file a try.
Thanks.
Create New Account
help
MSDE on Windows 2003 R2 box, new DL385G6 - Install Fails during SQL Services SQL Server I have been finding that I am having trouble with the Crystal Reports Server XI installation failing when it is dealing with SQL. So, as a thought and in case there was something wrong with my SQL portion of the isntall. I thought ok, I will try installing the actual MSDE application direct from Microsoft. So, I downloaded the MSDE for SQL 2000 (which is msde2000a.exe), set my switches and off to the races. It quit seconds left to the installation and bombed with the same errors as the Crystal Reports Server install. The error is the same whether I try to install MSDE by itself or
SQL Express: Failed Reinstall SQL Server Dear Setup Experts: I am trying to reinstall SQL Express after playing with it some. I uninstalled it, and now, it refuses to reinstall in the face. Any ideas what this log file means and how I can get SQL Express installed? I really do not want to have to reinstall my whole system. * ** ** Start of Log File Overall summary: Final result: SQL Server installation failed. To continue, investigate the reason for the failure, correct the problem, uninstall SQL Server, and then rerun SQL Server Setup. Exit code (Decimal): -2068643839 Exit facility code: 1203
Moving database decrease performance SQL Server I have moved database from one SQL2000 on win server to another standalone computer. Both SQL serverers have the same settings, same service pack, enterprise editions. On both SQL servers are tempDB, log file and mdf file on separate disks. The new SQL server is on better computer, has more RAM, beter disks, stronger proc, but all queries are there some guide for this scenario somewhere on the net? Any suggestions? Thank you, Simon SQL Server Programming Discussions SQL Server 2008 (1) SQL Server 2000 (1) SQL Server Books (1
SQL Express Installation Failed on New Windows XP Home SQL Server Hello: I installed SQL Express on my system. I uninstalled and reinstalled it a few times. Eventually, this hosed my system to some extent, and SQL Express would not install. I just had Windows XP Home reinstalled. I have reinstalled the software that I use. Yesterday, I tried to install SQL Express for the first time on this new installation. It failed with Wait on the backed up the entire partition, so I restored it. I am about to try installing SQL Express again today. What should I be considering first? (I am rather badly bitten / gunshy in with NT AUTHORITY \ LOCAL SERVICES. I simply used that for the other three. For SQL Express administrators, I made my account the administrator. My account is system administrator. I have
SQLServer Error: 802, 701, 733 SQL Server SQL Server 2008 on Win2008 R2 x64 Server, 8 GB RAM - running virtualized on VMWare ES-Server Every sunday some maintainance jobs are scheduled to run. Rebuilding indices and statistics fail with There is insufficient memory available in the buffer pool. [SQLSTATE 42000] (SaveAllSchedules) After this the server is no longer reachable: [298] SQLServer Error: 773, SQL Server Network Interfaces: The requested security package does not exist [SQLSTATE 08001] . . . [298] SQLServer Error