Get Column and table name from given Query

  • Get the all column and table name from sql query

    for example

    select emp_id, emp_name ,d.department_id

    from Emp e inner join department d on d.department_id=e.department_id

    where emp_id=10

    Output like

    Column name table name

    emp_id emp

    emp_name emp

    depatment_name emp/department

    Regards

    Srikant

  • When, how & why do you want to do this?

  • We just want to know the how many column and table used in sql select stament

  • From where? In what fron end?

  • The INFORMATION_SCHEMA views should give you all the information you need.

  • steveb. (9/21/2011)


    The INFORMATION_SCHEMA views should give you all the information you need.

    Not for a specific select statement that is not in a view.

  • Ninja's_RGR'us (9/21/2011)


    steveb. (9/21/2011)


    The INFORMATION_SCHEMA views should give you all the information you need.

    Not for a specific select statement that is not in a view.

    No not directly obviously, but it could be used as part of the query as a sub-query or similar to retrieve the information.

    but for what purpose , who knows?

  • you could get it from the execution plan, if it was in the cache.

    it's not easy, as xQuery's a little difficult, but it's in there.

    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!

Viewing 8 posts - 1 through 7 (of 7 total)

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