Michael
Michael

Reputation: 2657

SQL Server SSIS Export as XML Error: Name cannot begin with the '.' character, hexadecimal value 0x00. Line 1, position 40

I'm using SQL Server 2014 and SSIS. I have an OLE DB source using the below SQL command to output to a flat file destination - that is configured to save as .XML

This is my SQL:

DECLARE @XMLOutput XML
DECLARE @XMLOutputChar nvarchar(max)

;WITH XMLNAMESPACES('myNameSpace' as ns)

SELECT @XMLOutput =
(
SELECT field1 
FROM   table1 
    FOR XML PATH('Testing'),TYPE, ROOT('TestingLoader'),ELEMENTS XSINIL
)

SET @XMLOutputChar = '<?xml version="1.0" encoding="UTF-8"?>' + CONVERT(nvarchar(max),@XMLOutput)

SELECT @XMLOutputChar AS XMLOutput

However, when I try to import the XML file into a 3rd party application I receive the error:

Name cannot begin with the '.' character, hexadecimal value 0x00. Line 1, position 40.

Even if I try to view in MS Word I receive the error:

Unable to switch the encoding

Is this because I'm defining it as UTF-8 and nvarchar(max)?

Thanks.

Upvotes: 1

Views: 579

Answers (1)

Yitzhak Khabinsky
Yitzhak Khabinsky

Reputation: 22321

You re-posted this question on the Microsoft forum where I found it originally. I already answered it there. https://social.msdn.microsoft.com/Forums/en-US/f85ebd77-e7cb-4073-81e7-77a2ed5ab425/sql-server-ssis-export-as-xml-error-name-cannot-begin-with-the-character-hexadecimal-value?forum=sqlxml

Upvotes: 1

Related Questions