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,828
  • 3
  • 24
  • 51

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
  • 50,556
  • 8
  • 44
  • 80