SQL Server TRIM character

前端 未结 17 2228
感情败类
感情败类 2020-12-09 17:11

I have the following string: \'BOB*\', how do I trim the * so it shows up as \'BOB\'

I tried the RTRIM(\'BOB*\',\'*\') but does not work as says needs only 1 paramet

17条回答
  •  无人及你
    2020-12-09 17:32

    Trim with many cases

    --id = 100 101 102 103 104 105 106 107 108 109 110 111
    select right(id,2)+1  from ordertbl -- 1 2 3 4 5 6 7 8 9 10 11  -- last     two positions are taken
    
    select LEFT('BOB', LEN('BOB')-1) -- BO
    
    select LEFT('BOB*',1) --B
    select LEFT('BOB*',2) --BO
    

提交回复
热议问题