Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to extract a full list of tables and views used in a query?

I need to replicate a portion of a database so that we can avoid locking tables when a long query runs.

I have the execution plan. Is it possible to extract all the database objects the query touches?

share|improve this question
up vote 5 down vote accepted

If this was a one-off operation, I would be inclined to use SQL Sentry Plan Explorer (it's free!), rather than faff around writing a SQL Script.

Open the Execution Plan in Plan Explorer, navigate to the Query Columns pane and you can see a list of the objects that are used in the query.

enter image description here

share|improve this answer
Thanks Mark - that thing's great! Right clicking allowed me to copy it to Excel to muck about with. – Tom Wright Feb 19 at 14:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.