Using SQL Server “FOR XML”: Convert Result Datatype to Text/varchar/string whatever?

前端 未结 1 855
-上瘾入骨i
-上瘾入骨i 2020-12-06 20:20

I\'m struggling with this nearly one week now, and still haven\'t found any solution -.-

My goal is to receive an XML from a SQL Server by querying with the \"FOR XM

相关标签:
1条回答
  • 2020-12-06 20:46

    I knew I'd done something like this before, and I think this is what you're after:

    SELECT CAST((SELECT [Columns] FROM [Tables] FOR XML PATH('')) AS VARCHAR(MAX)) AS XmlData
    

    That will spit out whatever you've generated as XML as text data that Lotus Notes may well accept.

    Edit: You could change FOR XML PATH('') to FOR XML AUTO if you need the XML to be generated in another style.

    0 讨论(0)
提交回复
热议问题