sqlserver的换行

http://blog.csdn.net/sdandan/article/details/8424400


制表符: CHAR(9)
换行符: CHAR(10)
回车符: CHAR(13)

如:

print 'a'+CHAR(10)+'b'

结果为

a

b

如果想输出文本

则select 'a'+CHAR(13)+CHAR(10)+'b'

必须是CHAR(13)+CHAR(10),不是CHAR(10)+CHAR(13),因为文本中的是{CF}{CL},回车,换行

则输出文本为

a

b


--== 处理会员地址字段包含回车字符的情况
IF object_id('tempdb..#person_with_char13_10') is NOT NULL
      DROP TABLE #person_with_char13_10
      
SELECT person_id
INTO #person_with_char13_10
FROM dbo.person
WHERE 1=1
AND CHARINDEX(CHAR(13) + CHAR(10), street1) > 0
 
UPDATE person SET street1 = REPLACE(street1, CHAR(13) + CHAR(10), '' )
WHERE person_id IN (
      SELECT person_id FROM #person_with_char13_10
)
 
 
--== 处理会员地址字段包含|
IF object_id('tempdb..#person_with_shu') is NOT NULL
      DROP TABLE #person_with_shu
      
SELECT person_id
INTO #person_with_shu
FROM dbo.person
WHERE 1=1
AND CHARINDEX('|', street1) > 0
 
 
UPDATE person SET street1 = REPLACE(street1, '|', '' ) WHERE person_id IN (
      SELECT person_id FROM #person_with_shu
)


你可能感兴趣的:(sqlserver的换行)