Here i declare two variable 1st is @ValueToBeReplace and 2nd is @ValueReplaceBy . 1st value is user want to replace & 2nd is value which take place of 1st value . IN Query you see that i just use REPLACE Function.I hope you aware about this if not then click on replace function . First we add , to both side of column value like this ','+CityIds+',' .Since we know that REPLACE function takes 3 parameter In first parameter we set ','+CityIds+',' in second we set ','+@ValueToBeReplace+','
and in third we set ','+@ValueReplaceBy+',' . Another REPLACE function is used for remove the first and last comma which we add in columns.