如何使用sql for xml path('')但保留回车符

Jam*_*ish 5 xml sql

我有以下代码

select
    (
    select cast(Narrative as Varchar(max)) + char(13) 
    from officeclientledger 
    where ptmatter=$matter$ and ptTrans=4 
    for xml path (''), type
    )
Run Code Online (Sandbox Code Playgroud)

它提供的结果如下:

Cwm Taff NHS Trust医疗记录 ; Purby医学博士 ; (不包括空格,需要插入以便提出问题)

但是,有没有办法提供诸如此类的结果

Cwm Taff NHS Trust医疗记录

Purby医学博士

Jam*_*ill 7

使用SSMS中的网格功能结果无法完成此操作.但是,如果您使用结果文本选项并用CHAR(10)替换CHAR(13),您将获得所需的结果.