Click here to Skip to main content
11,496,146 members (461 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
See more: line

I am getting records from database(sql server)as comma separated.I am getting contact
titles as

greg w.workcerf,ashir ali,asdddfgjk

This is comma separater has been defined in sql function getCommaListTitle

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

greg w.workcerf,
ashir ali,

Any idea about what should i use in sql function instead of ','
Posted 5-Jul-12 23:06pm
If I understood correct, you need to go and change your SQL Function getCommaListTitle.

Here in your SQL function, after your ',' put CHAR(13); or CHAR(10);
This will insert carriage return(code 13) or newline feed(code 10) in the text leading to the text format as you are trying to get.
Manas Bhardwaj at 6-Jul-12 5:47am
This is correct +5!
Assuming you are doing it in C#.

string s = "greg w.workcerf,ashir ali,asdddfgjk";
string finalString = s.Replace(",", ",\r\n");    //in case it is goiing on windows form
string finalString = s.Replace(",", ",
");    //in case it is goiing on web form
Sandeep Mewara at 6-Jul-12 4:27am
Our interpretation differ here. Lets see!
Rahul Rajat Singh at 6-Jul-12 4:29am
interpretation are different but both our solutions are correct in their own way(perhaps not in the context of this question). +5 for your solution, liked it.
Manas Bhardwaj at 6-Jul-12 5:49am
This is correct. Personally, I would do it at SQL Server (but, that's just me :)). I voted 4.
HI All,
Thanks for your quick responses,
<br>', ''
 worked in sql server function .Now i am getting required output

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600

Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 6 Jul 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100