My data looks 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 can I remove the commas at the end of the lines? I must retain the commas between items, but I need to remove any from the end
I need to do this within a select statement, and I haven't been able to find a solution of applying a RegEx without writing a function (Which I would prefer to avoid)
I have one solution, but its particulary dirty and I would like to improve it. I'm using a set of nested REPLACE to replace 4 commas with 3, 3 with 2, and 2 with one, then remove the end one
Any ideas?
EDIT: Data is coming from an external system, so I have no control over that, otherwise I'd concatenate with commas correctly in the first instance. This statement I'm using will be run on SQL Server 2005