T-SQL XML 值丢失新的行格式
我已将 XML 文件加载到 SQL 服务器中。我查询此文件以提取具有值的节点。
问题是选择时新行字符丢失。如何保留格式,以便当我在网络上显示文本时,如果没有换行符,它不会显得凌乱。
有关详细信息,请参阅文本和屏幕截图
T-SQL 代码:
declare @Text xml ;
set @Text= '<?xml version="1.0" encoding="utf-8"?>
<topic>
<L1>
<Subject>Subject text</Subject>
<Details>
Story Details are
This is paragraph
Text after After two line breaks
Text after After two line breaks
</Details>
</L1>
</topic>'
;with t as (select @Text [xmlcolumn])
--select * from t
SELECT x.a.value('(Subject)[1]','nvarchar(max)') as [Subject]
, x.a.value('(Details)[1]','nvarchar(max)') as [Details]
FROM t
cross apply
t.xmlcolumn.nodes('//L1') x(a)