Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rtrim issues

Status
Not open for further replies.

bouwob

Programmer
Apr 12, 2006
171
US
ok I seem to be having troubles using rtrim and ltrim.

I have this sql

update table set description = lTRIM(rTRIM(description))

which should cut off the beginning and trailing white spaces but when I run

select distinct(description) from table order by description

after the trims

I get many results that look like this

'WRQ'
'WRQ '
'WRQ '

what is the deal?

tia

 
RTrim will not remove 'non-printable' characters, like TAB, CR, LF.

Try this...

Code:
update table set description = Replace(description, Char(9), '')

update table set description = Replace(description, Char(10), '')

update table set description = Replace(description, Char(13), '')

As always with update statements, make sure you have a good backup before running this.

-George

"the screen with the little boxes in the window." - Moron
 
what about this?

Code:
update table set description = replace(description, ' ', '')

This will replace any spaces in description with '' (nothing).

Hope this helps,

Alex

[small]----signature below----[/small]
I don't do any programming whatsoever

Ignorance of certain subjects is a great part of wisdom
 
man gmmastros you are on the ball today. Didnt even think about non "space" white spaces.

thanks alot.

AlexCuse

Had that thought but I just needed to remove starting and trailing spaces. And not spaces within the description. Thanks for the insight though.
 
Glad I could help. [smile]

-George

"the screen with the little boxes in the window." - Moron
 
>>>man gmmastros you are on the ball today.

So that means it must be a day [2thumbsup]

sorry about that, I didn't realize you could have spaces in the description. And I still don't think it would handle tabs, cr's or lf's.





[small]----signature below----[/small]
I don't do any programming whatsoever

Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top