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
 General SQL Server Forums
 New to SQL Server Programming
 Need New Line character in data

Author  Topic 

sqldevelop
Starting Member

1 Post

Posted - 2008-01-11 : 10:36:29
I have a need to have new line character in some data. I am trying to insert and retrieve the data with the new lines char in it, but it does work. I need the new line char in the data as I need to do some further processing whenever the new line starts.
Any ideas on how I can achieve this?
Thanks for the help.

This are the ways I have already tried, but does not work

create table mytest (col1 varchar(max))

insert into mytest values (' line1 ' + CHAR(13) + ' line2')

update mytest set col1 = (' line1 ' + CHAR(13) + CHAR(10) + ' line2')

update mytest set col1 = 'line1 \n
line2 \n
aa \n
line3 \n'

update user03.amitatest set col1 = 'line1 ' + CHAR(13) + CHAR(10) +
' line2 ' + CHAR(13) + CHAR(10) + 'aa ' + CHAR(13) + CHAR(10) + 'line3'

select col1 from mytest

The result set from the above select is -
line1 line2 aa line3

PeterNeo
Constraint Violating Yak Guru

357 Posts

Posted - 2008-01-11 : 10:39:05
Hi, view the results in text mode (Ctrl+T) by using char(13) + char(10).
Go to Top of Page

Jeff Moden
Aged Yak Warrior

652 Posts

Posted - 2008-01-12 : 22:51:46
Hey Jeff Smith... ya missed a presentation layer rant here ;-)

--Jeff Moden
Go to Top of Page
   

- Advertisement -