Remove Extra Commas From Beginning or Ending of a String
A simple and very short code to replace extra commas from the beginning or ending of a string. No need to explain the code.
DECLARE @str VARCHAR(50) = ',a,n,i,s,h,'
SELECT @str
SET @str = REPLACE(@str, ',', ' ')
SET @str = LTRIM(RTRIM(@str))
SELECT REPLACE(@str,' ', ',')
Comments
Post a Comment