Tables and fields used by a query

  • Hello,

    do you know a way (tools, scripts) to find all tables and fields used by a query ?

    I want find the tables and fields used by 'select', 'join', 'from' clauses and sub queries ...

    Thanks for you help.

  • Your question is odd. If you can see the query, it is inherently made up of what you are asking to see? Perhaps you can explain a little more what you are trying to achieve.

  • In fact, there are approximately 100 queries and I must know tables and fields used by those queries, so I'm trying to find a quick way to get this.

  • how about this idea:

    turn each query into a view, then use sp_depends VIEWNAME, then drop the views when completed?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Although it is included only for backwards compatibility ... look at the BOL explanation of the syscomments table which contains the text for all stored procedures. True you would have to manually go through and read each procedure, but it is a way that is fairly simple.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Lowell (11/7/2008)


    how about this idea:

    turn each query into a view, then use sp_depends VIEWNAME, then drop the views when completed?

    very nice, it's exactly what I need !!!! 😀

    thank you all for your help

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply