NVARCHAR字符串中插入换行符

NVARCHAR字符串中插入换行符

本文介绍了如何在SQL Server VARCHAR/NVARCHAR字符串中插入换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有看到与此主题相关的任何类似问题,因此我不得不针对当前正在研究的问题进行研究.我以为如果其他人有相同的问题,我会给出答案.

I didn't see any similar questions asked on this topic, and I had to research this for something I'm working on right now. Thought I would post the answer for it in case anyone else had the same question.

推荐答案

我在这里找到了答案: http://blog.sqlauthority.com/2007/08/22/sql-server -t-sql-script-insert-carriage-returns-and-new-line-feed-in-code/

I found the answer here: http://blog.sqlauthority.com/2007/08/22/sql-server-t-sql-script-to-insert-carriage-return-and-new-line-feed-in-code/

您只需连接字符串,然后在要换行的位置插入CHAR(13).

You just concatenate the string and insert a CHAR(13) where you want your line break.

示例:

DECLARE @text NVARCHAR(100)
SET @text = 'This is line 1.' + CHAR(13) + 'This is line 2.'
SELECT @text

这将打印出以下内容:

这篇关于如何在SQL Server VARCHAR/NVARCHAR字符串中插入换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 05:28