If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > Is there any function to trim trailing characters?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-04-11, 00:08
reddy_546 reddy_546 is offline
Registered User
 
Join Date: May 2010
Location: Hyderabad, India
Posts: 16
Is there any function to trim trailing characters?

I want to trim trailing 'A' from "ASIAAAAAA".
__________________
-PavanKumar M Reddy
Reply With Quote
  #2 (permalink)  
Old 03-04-11, 03:13
aflorin27 aflorin27 is offline
Registered User
 
Join Date: Apr 2008
Location: Iasi, Romania
Posts: 317
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
Iasi, Romania
Reply With Quote
  #3 (permalink)  
Old 03-05-11, 20:43
reddy_546 reddy_546 is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 03-16-11, 07:04
trvishi trvishi is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On