I have a column "A" that are separated by commas and I want to find all the unique values in Column A.
Here's a very short example:
Column A
111, 222
333
444
777,999
I want a query which gives me the following value:
Column C
111
222
333
444
777
999
Ignoring the obvious problems with your table design as alluded to in all the comments and accepting that this might prove very slow on a huge table here's how I might do it.
First... I would create a statement that would turn all the rows into one big massive comma delimited list.
Then use the table valued udf split described by this SO article to turn that massive string back into a table with a distinct clause to ensure that it's unique.
https://stackoverflow.com/a/2837662/261997
You can use the well-known Split function in combation with
outer apply
to split rows into multiple rows:Full code example: