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