Home Forums SQL Server 2008 T-SQL (SS2K8) How can I add encoding in output XML file like "<?xml version="1.0" encoding="ISO-8859-1"?>" RE: How can I add encoding in output XML file like "<?xml version="1.0" encoding="ISO-8859-1"?>"

  • I'll assume your query produces a single record with the XML data type, and as the UNION ALL expects data types to match, and that my idea assumed a different scenario, this won't quite work as written, however..

    You could use your query as a subquery as follows:

    SELECT '<?xml version="1.0" encoding="iso8859-1"?>' +

    (

    SELECT doc.col1, doc.col2, doc.col3

    FROM TestTable AS doc

    FOR XML PATH ('doc')

    )

    Let me know if that works for you...

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)