Results 1 to 4 of 4
  1. #1
    Join Date
    May 2010
    Location
    Hyderabad, India
    Posts
    16

    Unanswered: Is there any function to trim trailing characters?

    I want to trim trailing 'A' from "ASIAAAAAA".
    -PavanKumar M Reddy

  2. #2
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    I do not think to exist such a function in Sybase or any other RDBMS language. Plus that I did not understand exactly what the result should be: "ASI" or "ASIA".

    I am although pretty sure you may write a T-SQL function that:
    - has a string parameter
    - remove any spaces
    - reads the last letter of the string
    - WHILE the last but one letter is equal with the previously read one, remove the last letter from the string
    - returns the remaining string
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

  3. #3
    Join Date
    May 2010
    Location
    Hyderabad, India
    Posts
    16
    It should be "ASI"...The function should work as ltrim() or rtrim() in oracle.
    -PavanKumar M Reddy

  4. #4
    Join Date
    Sep 2003
    Location
    Switzerland
    Posts
    443
    Quote Originally Posted by reddy_546 View Post
    It should be "ASI"...The function should work as ltrim() or rtrim() in oracle.
    Unfortunately no in ASE. There is an rtrim, but it only trims space. Theres no provision to trim a user defined character.

    There is str_replace, but again, it doesnt accept wildcards. So, its basically all 'A's in a string.

    Maybe a feature request for Sybase.

Posting Permissions

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