Save linefeed-return charactes in a varchar column

  • Hi,

    I have use a HTML control TextArea to let users input free format text in it. Users can input save linefeed-return charactes (next line characters) in that textbox. But when I saved it in a varchar-datatyped column of a db table, those characters are saved as space blank characters. So, how can I save linefeed-return charactes in that varchar-datatyped column?

    Thanks.

  • John,

    You could replace them with char(13)

    create table #test(test varchar(8000))

    INSERT #test (test) VALUES ('This ' + char(13) + 'is a ' + char(13) + 'test' )

    select * from #test

    drop table #test

    Jan

  • Jan,

    But when you let user input free format text in an html TextArea and save it in an SQL server table column who belongs to varchar type, how do you know linefeed return characters saved in that column by looking in the column contents? I mean using SELECT mycolumn from mytable in QA, how such do special linefeed return characters look like?

    Thanks.

  • John,

    The easiest thing is save your result to a file, result will be same as user entered in free format text (including line feeds)

    Char(13) is not a visible character

     

  • The problem is that carriage returns mean nothing in HTML... your app has to capture user induced line breaks as <br> in order for them to mean anything in HTML.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 5 posts - 1 through 4 (of 4 total)

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