I have a large string in the form of a query, like for example:
“SELECT column_name1, column_name2, column_name3, column_name4 FROM table1 JOIN table2 ON table1.field1 = table2.field1” (the original query will have about 30 column names from joins of about 6-8 tables)
Now I just want the column names from this string. How can I achieve that?
Thank you in advance.
There are a number of ways including LINQ and RegEx but here’s a process that uses string’s Split function. Do note that this loop assumes that the column names will be pretty monotonic and will not assume special cases such as commas or spaces in column names.