Working through an odd issue that the moment and trying to find a solution. If we have a string variable (@string) how might we drop the last character of the string, ONLY if the last character is an s?
Asked
Active
Viewed 2,081 times
1 Answers
5
It seems a bit odd issue but here's how to do it.
DECLARE @string NVARCHAR(10)
SET @string = 'Tests'
SELECT
CASE
WHEN RIGHT(@string,1) IN ('s','S') THEN SUBSTRING(@string,1,LEN(@string)-1)
ELSE @string
END AS string
Danielle Paquette-Harvey
- 2,029
- 1
- 17
- 26
LEFTinstead ofSUBSTRINGis slightly shorter – Charlieface Jan 22 '21 at 02:09