Remove the last character in a string in T-SQL?

前端 未结 21 2331
不思量自难忘°
不思量自难忘° 2020-12-07 09:22

How do I remove the last character in a string in T-SQL?

For example:

\'TEST STRING\'

to return:

\'TES         


        
21条回答
  •  遥遥无期
    2020-12-07 10:04

    This will work even when source text/var is null or empty:

    SELECT REVERSE(SUBSTRING(REVERSE(@a), 2, 9999))
    

提交回复
热议问题