如何在SQL Server 2014中的两个语句之间提供换行符。 [英] How to give a line break between two statements in SQL server 2014.
问题描述
我试图使用Char(13)+ char(10)在我的存储过程中分隔两个语句。但它不能正常工作。我的代码如下..
DECLARE @ProjectDescription varchar(100);
SELECT @ProjectDescription = Name From SubProjectsList;
SET @Description ='All Company'+ Char(13)+ char (10)+ @ProjectDescription;
我希望我的输出为......(假设Project1是@ProjectDescription的值)
'AllCompany
Project1'
但它总是像'AllCompany Project1'
I am trying to separate two statements in my stored procedure using Char(13)+char(10).But it is not working.My code as below..
DECLARE @ProjectDescription varchar(100);
SELECT @ProjectDescription = Name FROM SubProjectsList;
SET @Description = 'All Company'+ Char(13)+char(10) + @ProjectDescription;
I want my out put as ...(Suppose Project1 is tha value of @ProjectDescription)
'AllCompany
Project1 '
but its always coming like 'AllCompany Project1 '
推荐答案
You just concatenate the string and insert a CHAR(13) where you want your line break.
Example:
DECLARE @text NVARCHAR(100)
SET @text = 'This is line 1.' + CHAR(13) + 'This is line 2.'
SELECT @text
This prints out the following:
This is line 1.
This is line 2.
http://blog.sqlauthority.com/2007/08/22/sql-server-t-sql-script-to-insert -carriage-return-and-new-line-feed-code-code / [ ^ ]
这篇关于如何在SQL Server 2014中的两个语句之间提供换行符。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!