Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New line in TSQL

I am getting records from database as comma separated. I am getting contact titles as:

greg w.workcerf, ashir ali, asdddfgjk

This is comma separated has been defined in SQL function getCommaListTitle()

What i want is to get these record on new lines as

greg w.workcerf,
ashir ali,
asdddfgjk

Any idea about what should i use in sql function instead of ','

like image 747
user1506097 Avatar asked Jul 06 '12 07:07

user1506097


People also ask

How do I add a new line in SQL query?

SQL Server -- using new line feed: CHAR(10) SELECT 'First line. '+ CHAR(10) + 'Second line. ' AS 'New Line' -- using carriage return: CHAR(13) SELECT 'First line. '+ CHAR(13) + 'Second line.

What does \n mean in SQL?

The "N" prefix stands for National Language in the SQL-92 standard, and is used for representing Unicode characters.

How do I cut a new line character in SQL?

Remove and Replace Carriage Returns and Line Breaks in SQL Using SQL to remove a line feed or carriage return means using the CHAR function. A line feed is CHAR(10); a carriage return is CHAR(13).


1 Answers

Append after the comma in getCommaListTitle, CHAR(13) + CHAR(10) for a new line

CHAR(13) is a new line char and CHAR(10) is a line feed.

See http://msdn.microsoft.com/en-us/library/ms187323.aspx

like image 73
Johnno Nolan Avatar answered Oct 14 '22 01:10

Johnno Nolan