Results 1 to 6 of 6

Thread: replace funtion

  1. #1
    Join Date
    Feb 2005
    Posts
    76

    Unanswered: replace funtion

    how do i write a replace function that will replace a certain character with a return key (ie what happens when we do Ctrl+return key in SQL Enterprise table... so that the rest of the cell data in the column is on the next line?!

    SELECT REPLACE(tasks, '/', '????') AS EXPR1
    FROM log_descriptions


    what should ???? be?

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    I think you want the char function with the ascii code for line break.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Mar 2005
    Location
    Netherlands
    Posts
    280
    I alway forget the ANSII code for a line break so I use this instead:
    Code:
    SELECT REPLACE(tasks, '/', '
    ') AS EXPR1
    FROM log_descriptions
    Works like a charm

  4. #4
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    or this, maybe easier to read in a big script

    declare @cr char(1)
    set @cr = '
    '
    select 'a' + @cr + 'b'

  5. #5
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Char(13)+char(10)
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  6. #6
    Join Date
    Mar 2005
    Location
    Netherlands
    Posts
    280
    13 & 10... I'll try to rember that

    So summing this up we got:
    Code:
    DECLARE @cr CHAR(1)
    SET @cr = CHAR(13) + CHAR(10)
    SELECT 'a' + @cr + 'b'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •