I have a database column and its give a string like ,Recovery, Pump Exchange,.
,Recovery, Pump Exchange,
I want remove first and last comma from string.
Expected Result :
Using LEN could backfire because LEN ignores trailing spaces. These could be added because of ANSI_PADDING defaulting to ON. So, you'd need RTRIM.
For completeness, I've added LTRIM too...
REVERSE(SUBSTRING(REVERSE(RTRIM(LTRIM(SUBSTRING(MyCol, 2, 8000)))), 2, 8000))