how to save newline in varchar column

  • I admit this is a silly question. But really appreciate if you could help. I have formatted text saves in a varchar column and the format, particularly newline, must be retrievable. However my query result shows that the newline is gone. So should I save the newline if possible? Or what can I do if varchar doesn't do newline?

    Thanks a lot.

    John

  • I'm not quite sure how to answer this as I do not know what your front-end is doing.  But here is an example of how to force line feeds: 

    DECLARE @LineFeed TABLE( Verbiage varchar(50))

    INSERT INTO @LineFeed

    SELECT 'THIS ' + CHAR(10) + 'AND THAT'

    INSERT INTO @LineFeed

    SELECT 'THIS ' + CHAR(13) + 'OR THAT'

    SELECT * FROM @LineFeed

    I wasn't born stupid - I had to study.

  • thanks for reply.

    I'm importing data from Informix where text format is well saved in a blob column. the newline in the Informix export file is clear. but after imported into SQL, mapped to varchar/varchar(max), the newline is gone. query result doesn't have newline so doesn't have line break. 

    if there isn't a direct solution, I can try pre-process the exported file adding in the 'char(n)' probably...

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply