回车SQL Server

时间:2014-11-20 23:34:33

标签: sql-server sql-server-2008

嘿伙计们,我正在研究这个问题,并且我不断得到我想要的输出,我想让它分开

代码如下:

SELECT e.clientcode,
       clientname,
       staffcode        AS ServiceEM,
       debttrandate     AS InvoiceDate,
       debttranrefalpha AS InvoiceNbr,

       dd.feenarrative  AS narrative,

       dd.amount        AS BillAmount
FROM   tblengagement e
       INNER JOIN tblclientservices cs ON cs.contindex = e.contindex
       INNER JOIN tblstaff s ON s.staffindex = cs.servmanager
       INNER JOIN tbltrandebtor d ON d.contindex = e.contindex AND d.contindex = cs.contindex
       INNER JOIN tbltrandebtordetail dd ON dd.debttranindex = d.debttranindex AND dd.debtdetservice = cs.servindex

WHERE  dd.debtdetservice = 'taxcomp' AND 
        d.DebtTranType=3 and 
        DebtTranDate between 'jan 1 2014' and 'oct 31 2014' 
        and DebtTranRefAlpha='72598'

现在列dd.feenarative在第一行的一行中显示Aaa....BBB...CCC...DDD的输出,而不是显示

aaa

bbb

ccc

ddd 

我知道我需要做一些回车但是我已经尝试了一些事情,例如在选择之前添加declare @crlf varchar(2000)

CAST(+dd.FeeNarrative as varchar(2000)),+ ' ' +Cast( dd.FeeNarrative as varchar(2000)) + ''

在选择中但我没有完成它......我用各种不同的方式玩弄它。

1 个答案:

答案 0 :(得分:0)

输出数据显示它是单个记录。即使你有回车数据,sqlserver也会显示为一个继续字符串。我建议你,你可以在ui级别检查。

如果您仍有问题,则可以使用CHAR(10)+ CHAR(13)组合进行CR。或者您可以使用< \ br>或\ n以html显示。

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/9e53979f-e477-49da-b6b0-ddbf70735320/carriage-returnline-feedchar10-and-char13-help?forum=transactsql

carriage return in sql server 2012

New line in sql server 2008 r2

Use of REPLACE in SQL Query for newline/ carriage return characters