CHAR(10) sometimes work

  • IN SQL

    I want to print for example

    Ali

    is going to Alex

    so I said

    declare @x varchar(max) set @x = 'Ali' + CHAR(10) + 'is going to Alex'

    in some servers it work very well in tohers not even with using CHAR(13)

    the output appear in one line instead of two ones

    any idea how to fix that, and make it work in all servers

  • how are you determining it doesn't display right on some servers but not other servers?

    the data will have the control characters no matter what in them, but it's up to the presentation layer to determine whether to display something as multi line or not.

    note, for example, in SSMS, the gridview never wraps to multi line, only text view does; could it be something that simple?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • There are two different ways to display query results in the SQL Server Management Studio (SSMS) - text or grid view. Per the previous post, they act differently.

    I guess the question is where are you determining it does not work??

    Remember, WINDOWS versus UNIX differs in end of line (EOL) markers. WINDOWS = CR+LF: CR (U+000D) followed by LF (U+000A), UNIX = LF only.

    Something many people forget when transferring files.

    We wait to hear back from you on what tool you are using to determine that the EOL characters are not there.

    John Miner
    Crafty DBA
    www.craftydba.com

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

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