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.
Tof theTestingLoaderroot node name.<?xml version="1.0" encoding="UTF-8"?><TestingLoader...