Question: How can I correctly add line breaks to VARCHAR or NVARCHAR strings in SQL Server?
A developer recently faced this challenge and found limited readily available solutions.
Answer: SQL Server uses character codes to represent line breaks. For the standard DOS/Windows line break (CRLF - carriage return and line feed), use this code:
<code class="language-sql">CHAR(13) + CHAR(10)</code>
Here's how to use it to create a multi-line string:
<code class="language-sql">'This is the first line.' + CHAR(13) + CHAR(10) + 'This is the second line.'</code>
The above is the detailed content of How to Add Line Breaks to SQL Server VARCHAR/NVARCHAR Strings?. For more information, please follow other related articles on the PHP Chinese website!