My data is as follows
MyText
-------
some text, some more text, even more text,,
some text,,,,
some text, some text,,,
some text, some more text, even more, yet more, and again
I would like to achieve:
MyText
-------
some text, some more text, even more text
some text
some text, some text
some text, some more text, even more, yet more, and again
How to remove commas at the end of lines? I have to keep commas between the elements, but I need to remove any of the end.
I need to do this in the select statement, and I could not find a solution for applying RegEx without writing a function (which I would prefer to avoid)
I have one solution, but its especially dirty, and I would like to improve it. I use a set of nested REPLACE to replace 4 commas with 3, 3 with 2 and 2 with one, and then remove the end
Any ideas?
EDIT: The data comes from an external system, so I do not control this, otherwise I would first combine the commas. This statement that I use will be run on SQL Server 2005