Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    2

    Question Unanswered: sql to replace spaces with underscores

    Could any one give me a sql to replace spaces with underscores

    example "file name 1 2 3" -> "file_name_1_2_3"

  2. #2
    Join Date
    Sep 2003
    Location
    Milan, Italy
    Posts
    130

    Re: sql to replace spaces with underscores

    Originally posted by sat1
    Could any one give me a sql to replace spaces with underscores

    example "file name 1 2 3" -> "file_name_1_2_3"
    SQL> select translate ('file name 1 2 3', ' ', '_') from dual;

    TRANSLATE('FILE
    ---------------
    file_name_1_2_3

  3. #3
    Join Date
    Oct 2003
    Posts
    2

    Exclamation Re: sql to replace spaces with underscores

    Thanks alberto,
    the problem arises when there are more than one consecutive spaces to be replaced with a single underscore.

    example : fileSSSSname -> file_name (where S is a space)

    I finally used PL/SQL to do the same. The question is, Can we do it with SQL?

    -------------------------------------------

    Originally posted by alberto.dellera
    SQL> select translate ('file name 1 2 3', ' ', '_') from dual;

    TRANSLATE('FILE
    ---------------
    file_name_1_2_3

Posting Permissions

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