Suppose we have a string :
Declare @CatId as varchar(100)
Set @CatId = '10,20,30,40,50,60,70,80,'
To remove last comma from the above string,
write the SQL statement
Select reverse(stuff(reverse(@CatId), 1,
1, '')) As Ids
It will give the result :
10,20,30,40,50,60,70,80

JackPosted Nov 17, 2019, 7:21 AM
Instead of reverse this will also work Stuff(@CatId, LEN(@CatId), 1, '')) As Ids
Gakenh01Posted Dec 6, 2016, 7:48 AM
Very nice, I am using it in a stored procedure and it saved me a lot of work. Thank you.