i have large string in SQL Server. I want to truncate that string to 10 or 15 character
Original string
this is test string. this is test string. thi
I think the answers here are great, but I would like to add a scenario.
Several times I've wanted to take a certain amount of characters off the front of a string, without worrying about it's length. There are several ways of doing this with RIGHT() and SUBSTRING(), but they all need to know the length of the string which can sometimes slow things down.
I've use the STUFF() function instead:
SET @Result = STUFF(@Result, 1, @LengthToRemove, '')
This replaces the length of unneeded string with an empty string.