SQLTeam.com | Weblogs | Forums

How to remove ONLY V as the last char


#1

How can I remove the last char ONLY if it is Capital V, otherwise, do not nothing.
Please see the results below. Thank you in advance.

DECLARE @cx VARCHAR(40)
SET @cx = 'testV' -- 'testd'
SELECT LEN(@cx)

SELECT LEFT(@cx, LEN(@cx) - 1)

select ASCII('V')

-- Result want:


test
testd


#2
select 
   case 
      when right(columnhere, 1)='V' then 
         left(columnhere, len(columnhere)-1) 
      else columnhere 
    end AS aliashere
from tablehere;

#3

Thank you.