Insert newline character in SQL Server VARCHAR/NVARCHAR string
While this topic may not have been mentioned explicitly in previous discussions, it is an issue developers often encounter. To solve this problem, let us explore the solution to insert newline character in VARCHAR/NVARCHAR strings in SQL Server.
Solution:
To insert a newline character in a VARCHAR/NVARCHAR string, you can use the following characters:
For DOS/Windows-conforming newlines (CRLF), combine char(13) with char(10) as follows:
<code class="language-sql">'这是第一行。' + CHAR(13) + CHAR(10) + '这是第二行。'</code>
By adding these characters, you effectively create newlines in VARCHAR/NVARCHAR strings in SQL Server.
The above is the detailed content of How Do I Insert Line Breaks into SQL Server VARCHAR/NVARCHAR Strings?. For more information, please follow other related articles on the PHP Chinese website!