The c# application I'm working with executes many T-SQL SELECT queries that are stored as strings in a database.
These queries almost all involve selecting data from and joining with several tables from within the database.
Certain combinations should not be permitted, e.g. column 1 from table X should not be returned if table Y is joined on table X. A simpler example might be "Never include data from table Z"
There are many such rules and currently it is down to the author of the SQL to check that the data returned does not violate any of these rules.
I cannot edit the database in any way.
What options are there for me to determine whether a specific query violates one of these rules?
Is it possible to determine what tables/columns are accessed in a query?
I would need the solution to be reliable, I have considered parsing the SQL e.g. by using a Regex but I think this falls somewhat short of the "reliable" requirement.