views:

4142

answers:

2

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

I.E. 'TEST STRING'

to return:

'TEST STRIN'

thanks Dave

+8  A: 

e.g.

DECLARE @String VARCHAR(100)
SET @String = 'TEST STRING'

-- Chop off the end character
SET @String = LEFT(@String, LEN(@String) - 1)

SELECT @String
AdaTheDev
Alternatively: SELECT LEFT(YourColumnName, LEN(YourColumnName) - 1) FROM YourTable
Kyle B.
A: 

Try this:

select substring('test string', 1, (len('test string') - 1))
Adrien
Thanks this is exactly what I was looking for.
Daveed