Q:

How do I parse a SQL query to determine its tabular depencencies?

Assume I have a query, eg:
SELECT * FROM POTATO LEFT JOIN TUBER ON POTATO.delicious = TUBER.delicious

Is there a library or tool that will take that query and return ["POTATO,"TUBER"], such that I can sequence a series of queries logically?

A:

Probably the easiest thing to do is execute the SQL with SET STATISTICS XML ON. When you do that, you'll get two resultsets: the resultset of the query and a resultset containing the query plan as XML, contained as the first column in the last row. 
Once you have the query plan as XML, follow these instructions to get a list of all the attributes, then filter for "Table" and inspect the results.

