Rtrim... ish

Soldato
Joined
18 Oct 2002
Posts
6,795
hi guys,

i've got some data i want to apply an rtrim to, but it doesn't necessarily have spaces at the end of the field. example:

Code:
Celebrations                                   [D]

How can i remove all the annoying spaces and keep the "[D]", or whatever it is, at the end?

B@
 
probably not the best solution, but the following should work:

PHP:
declare @myval nvarchar(100)
set @myval = 'Celebrations                                       [D]'
select replace(replace(replace(replace(replace(@myval,'     ',' '), '    ', ' '), '   ',' '),'  ',' '), '  ',' ')

Tried with various lengths of spacing, and it seems to work.

this works perfectly, thanks very much!!

B@
 
Back
Top Bottom