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

前端 未结 21 2372
不思量自难忘°
不思量自难忘° 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:00

    If your coloumn is text and not varchar, then you can use this:

    SELECT SUBSTRING(@String, 1, NULLIF(DATALENGTH(@String)-1,-1))
    

提交回复
热议问题