How do I remove the last character in a string in T-SQL
?
For example:
\'TEST STRING\'
to return:
\'TES
Try this
DECLARE @String VARCHAR(100)
SET @String = 'TEST STRING'
SELECT LEFT(@String, LEN(@String) - 1) AS MyTrimmedColumn
To update the record by trimming the last N characters of a particular column:
UPDATE tablename SET columnName = LEFT(columnName , LEN(columnName )-N) where clause
@result = substring(@result, 1, (LEN(@result)-1))