Text Field

  • Does anybody knows how to insert a carriage return into a text field? I have tried to use the ASCII code, it does not work.

    Thanks!

    --- Lu

  • When you say that inserting the ASCII code for a CR doesn't work, what do you mean.  How are you going about verifying that it doesn't work?

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • I have added Chr(13) and Chr(10) in the string variable to update text field. But when I pulled the text back into my application. It did not show the carriage return there.

    Thanks!

    --- Lu

  • Consider this example:

    declare @table table (T1 text)

    insert into @table (T1)

    select 'test' + char(13) + ' test2'

    select * from @table

    In order to 'see' the results on two lines, you must view the query results in text (not grid).  This shows that SQL Server is storing the CHAR(13) in the column.  I would take this to mean that your application is not handling the results correctly. 

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • John is spot on...

    I'll also add that storing text columns in the database is bad for too many reasons to post here.  If you must store text that execeeds 8K characters and must not be parsed into multiple rows, store the info in a file and store the file name in the table.

    --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)

  • Thanks guys so much!

    I have tried to put <BR> in the text string and it worked when the text field loaded into a rich textbox field.

     

    Thanks!

     

  • Outstanding... thank you for the feedback.

    --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 7 posts - 1 through 6 (of 6 total)

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