I need to parse SQL to get all:
- Table names after INSERT clause,
- Tables after FROM, JOINs (including CROSS JOIN as comma ',' operator) clauses,
- The same with OPENQUERY or any other subqueries.
Each statement is one-liner SQL, without any extra spaces, comments, or new lines. Each query is INSERT-statement.
I have almost working regex: https://regex101.com/r/iS2fK9/1.
But it has a problem: regex cathes only first FROM/JOIN statement. Or only last if I apply greedy quantificators.
Ideal result is syntax tree. But simple list of named group will be sufficient.