Thursday, March 5, 2009

How to remove new line characters and Tab's in the SQL output

How to remove new line characters and Tab's in your SQL output


select comment from emp

Result (Comment column value is )

John M.
This was a
Fine piece of
work.

select REPLACE(REPLACE(REPLACE(comment, CHR(10)), CHR(13)), CHR(9)) comment from emp

Result (Comment column value is )

John M.This was a Fine piece of work.

18 comments:

  1. This is very useful command.It help me out.Thanks

    ReplyDelete
  2. Hi
    That is great for replacing. How would I search a column to find all the new line characters (made from a windows PC) first before replacing them?
    Thanks

    ReplyDelete
  3. Wonderful post :) it helped me fruitfully :) Tons of thanks

    ReplyDelete
  4. Hi ...
    I must say
    Sairamgoud .This was a Fine piece of work.

    :-)

    Cheers
    Naseer

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Thank you so much... it's really saved me a lot..
    awesome job dude..!!!

    ReplyDelete
  7. also can use:
    regexp_replace(comment, chr(9)||'|'||chr(10)||'|'||chr(13), '')

    ReplyDelete
  8. thanks!! it fixes my problem . . . .

    ReplyDelete
  9. Cool.. it works in all my scenarios...
    Thanks dude...

    ReplyDelete
  10. Whoa!! it worked so well for my script where i was trying hard to get this.

    ReplyDelete
  11. Whoa!It really worked well in my case, i was trying hard to find something like this.

    ReplyDelete
  12. Hi Sairam,

    A ton of thanks. God Bless you..!!

    Regards,
    RK

    ReplyDelete
  13. Appreciate the post. Sorted me out.

    ReplyDelete