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,471
  • 17
  • 87
  • 173
Ankush
  • 337
  • 2
  • 9

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
  • 39,662
  • 14
  • 68
  • 78