如何在 nvarchar 中正确插入换行符 [英] How to correctly insert newline in nvarchar

查看:36
本文介绍了如何在 nvarchar 中正确插入换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要制作一个脚本,该脚本采用一些富文本(html 文本)并将其转换为常规文本.我想要做的是用换行符替换所有 <br> 标签.我试图用替换功能来做到这一点:

I need to make a script that takes some rich text (html text) and transform it to regular text. What I want to do is replace all <br> tags with newline. I tried to do this with replace function:

set @rich_text_to_modify = replace(@rich_text_to_modify,'<br>', CHAR(13)+CHAR(10))


标签被删除,但不插入换行符.知道我做错了什么吗?

The
tags get removed but newlines are not inserted. Any idea what I am doing wrong?

推荐答案

问题在于您在 SSMS 上的设置,而不是数据没有换行符.

The problem is your setting on SSMS, not that the data doesn't have a line break.

转到:<代码>工具 ->选项 ->查询结果 ->SQL Server ->结果到网格 ->复制或保存时保留 CR/LF 并确保勾选该选项.

Go to: Tools -> Options -> Query Results -> SQL Server -> Results to Grid -> Retain CR/LF on copy or Save and make sure the option is ticked.

这篇关于如何在 nvarchar 中正确插入换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆