如何使用sql作为xml路径('')但保留回车符
我有以下代码
select
(
select cast(Narrative as Varchar(max)) + char(13)
from officeclientledger
where ptmatter=$matter$ and ptTrans=4
for xml path (''), type
)
,可以提供如下结果:
Cwm Taff NHS 信托医疗记录 ; Purby 医生医疗记录 ; (不包括空格,为了提问而需要插入)
但是,有没有办法提供结果,例如
Cwm Taff NHS 信托医疗记录
珀比医生的医疗记录
i have the following piece of code
select
(
select cast(Narrative as Varchar(max)) + char(13)
from officeclientledger
where ptmatter=$matter$ and ptTrans=4
for xml path (''), type
)
which deliver results such as:
Cwm Taff NHS Trust Medical Records
; Dr Purby Medical Records ;
(excluding spaces, needed to insert for the purpose of asking the question)
however, is there a way of delivering the results such as
Cwm Taff NHS Trust Medical Records
Dr Purby Medical Records
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 SSMS 中的结果网格功能无法完成此操作。但是,如果您使用结果文本选项并将 CHAR(13) 替换为 CHAR(10),您将获得所需的结果。
This can't be done using the results to grid functionality in SSMS. However, if you use the results to text option and replace your CHAR(13) with CHAR(10), you'll get the desired results.
我遇到了同样的问题,并且无法使用 Char(10),因为接收系统需要 Char (13)。所以我使用下面的查询来替换结果中的值并且它起作用了。
I am hitting the same problem and i can't use Char(10) because the receiving system expect Char (13). So I used below query to replace the value in my result and it worked.
当我必须使用 SSMS 并希望查看请求的值进行测试时,我使用打印命令。
When I have to use SSMS and want to see the values like requested, for testing, I use the print command.