New Line character in SQL Server
Generally we use ‘\n’ as new line character. If we write the same in SQL server Query Analyzer it won’t work. 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.
Now, let’s see how to create a new line in SQL Server. It is a very simple script and very useful when we have to do run print something or generate scripts.
Below I illustrated two examples which are very easy to understand.
In the first example there are no new line chars inserted where as in the second example, a new line char is inserted and the lines are separate with a new line.
Example -1 :
Example – 2:
(‘Mindfire solutions,’ + char(10) + ‘IDCO Tower 2000,’ + char(13)+ ‘Bhubaneswar’) Both char(10) and char(13) are used for new line character.(‘Mindfire solutions,IDCO Tower 2000,Bhubaneswar’)