全部博文(69)
分类: 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