Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 inserting CRLF

Author  Topic 

macsterling
Yak Posting Veteran

56 Posts

Posted - 2009-01-12 : 22:13:27
I am conatenating several "note" columns into a single Master Note column for display on a screen. If I just say Master = note1 + note2, they are run together. What I need is to insert a CRLF after the end of each note, so the next will start on a new line. (will probably also stick in a 'Note 1: ==========' and a 'Note 2: ==========' between them to make things clear (the notes are often several lines long.

I have tried all sorts of ascii(13) ascii(10) combinations, but can't get it right. any suggestions?

Thanks,
Mac

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-12 : 22:14:50
You can do this with CHAR(10) and CHAR(13), however this shouldn't be done inside T-SQL but rather it should be done in your application. Just return note1 and note2 as separate columns and then format them as necessary using your application code.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

macsterling
Yak Posting Veteran

56 Posts

Posted - 2009-01-12 : 22:48:14
I don't have control inside the app. I am doing the conversion from an older system to the new one - just building the tables. It is the old two pounds in a one pound jar routine. If the old system has CRLFs they come over fine. I just can't get the syntax correct to put new ones in.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-13 : 00:07:11
write a UDF to do concatenation along with CHAR(10) & CHAR(13) or use FOR XML PATH if you're using sql 2005 or later
Go to Top of Page
   

- Advertisement -