SQL Server TRIM character

前端 未结 17 2177
感情败类
感情败类 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:27

    SqlServer2017 has a new way to do it: https://docs.microsoft.com/en-us/sql/t-sql/functions/trim-transact-sql?view=sql-server-2017

    SELECT TRIM('0' FROM '00001900'); -> 19

    SELECT TRIM( '.,! ' FROM '# test .'); -> # test

    SELECT TRIM('*' FROM 'BOB*'); --> BOB

    Unfortunately, RTRIM does not support trimming a specific character.

提交回复
热议问题