gpt4 book ai didi

sql - 如何将 sql 用于 xml 路径 ('')但保留回车符

转载 作者:数据小太阳 更新时间:2023-10-29 01:53:52 24 4
gpt4 key购买 nike

我有如下一段代码

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

它提供的结果如下:

Cwm Taff NHS Trust Medical Records ; Dr Purby Medical Records ; (excluding spaces, needed to insert for the purpose of asking the question)

但是,有没有一种方法可以提供这样的结果

Cwm Taff NHS Trust Medical Records

Dr Purby Medical Records

最佳答案

这无法使用 SSMS 中的结果网格化功能来完成。但是,如果您使用结果到文本选项并将 CHAR(13) 替换为 CHAR(10),您将获得所需的结果。

关于sql - 如何将 sql 用于 xml 路径 ('')但保留回车符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6113450/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com