Stored Procedure output has junk character at the beginning of the file

  • I have SP that generates the output in XML format. The file is generated correctly with all tags. However, at the beginning of each file I see couple of binary (junk) characters. Because of these characters, XML validation is failing. The output is generated by executing bcp command with queryout parameter.

    Any help is appreciated.

    Thanks

  • byanaman1 (10/20/2014)


    I have SP that generates the output in XML format. The file is generated correctly with all tags. However, at the beginning of each file I see couple of binary (junk) characters. Because of these characters, XML validation is failing. The output is generated by executing bcp command with queryout parameter.

    Any help is appreciated.

    Thanks

    Hi and welcome to the forum.

    What you are seeing is the BOM, Byte Order Mark. This means that the output is in a Unicode Transformation Format (UTF), the BOM indicates the endianness of the file. This should not cause an error unless the BOM does not match the XML encoding tag in the XML header.

    If an XML is generated in SQL Server from a UTF/N(VAR)CHAR, it is set as UTF-16, no other options available. With single byte (VAR)CHAR other encodings i.e. ASCII/UTF-8/Windows can be used. Note that UTF-8 can have a BOM, which serves the purpose of distinguishing it from other UTFs but it's inapplicable as an order mark as the it is a single byte transformation.

    😎

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply