0

I have one input string 'abcdefg,,,,,,,ghijk,,,,,lmno' and we want an output of 'abcdefg,ghijk,lmno' in SQL Server.

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
Ankush
  • 347
  • 2
  • 10

1 Answers1

1

Based on this solution you can replace multiple , with a single , like this:

SELECT REPLACE(REPLACE(REPLACE('abcdefg,,,,,,,ghijk,,,,,lmno', ',', '<>'), '><', ''), '<>', ',')

demo on dbfiddle.uk

Sebastian Brosch
  • 42,106
  • 15
  • 72
  • 87