0

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?

Carbon
  • 3,054
  • 1
  • 21
  • 43

1 Answers1

1

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.

John Wu
  • 47,831
  • 8
  • 41
  • 73