Chinaunix首页 | 论坛 | 博客
  • 博客访问: 130718
  • 博文数量: 69
  • 博客积分: 595
  • 博客等级: 中士
  • 技术积分: 670
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-16 17:37
文章分类

全部博文(69)

文章存档

2017年(2)

2016年(9)

2015年(13)

2014年(30)

2012年(4)

2011年(2)

2010年(2)

2009年(5)

2008年(2)

我的朋友

分类: SQLServer

2014-09-12 02:28:59

We have two different options to get new line:

Line Feed – LF – \n – 0x0a – 10 (decimal)
Carriage Return – CR – \r – 0x0D – 13 (decimal)

The question that arises is – why is it so?   The reason is simple. Different operating systems have a different way of understanding new line. 

Mac only understands ‘\r’ as new line, while Unix and Linux understand ‘\n’ as new line character. OS windows needs both the characters together to interpret as new line, which is ‘\r\n’. This is the reason why a file created in one OS does not open properly in another OS and makes it messy.

Example:
use AP
go

Declare @format varchar(100)
set @format = (SELECT VendorName + CHAR(13) + CHAR(10)
+ VendorAddress1 + CHAR(13) + CHAR(10)
+ VendorCity + ', ' + VendorState + ' ' + VendorZipCode
FROM Vendors
WHERE VendorID = 1)
print @format

---------------------------------------------
US Postal Service
Attn:  Supt. Window Services
Madison, WI 53707

阅读(412) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~