SQL query help

  • I am looking for select statement against system tables/views to get following result set. Is it possible?

    view_name

    view_column_name

    table_name

    table_column_name

    I want to link column in a view to column in base table. I can live ignoring derived columns in view that uses functions.

  • Something like this?

    SELECT T.Table_Type, T.Table_Name, C.Column_Name

    FROM INFORMATION_SCHEMA.TABLES T

    INNER join INFORMATION_SCHEMA.COLUMNS C ON T.Table_Name = C.Table_Name

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • Here is example of what I am looking for

    --Here is sample view definition

    create view individual

    select person.first_name as FirstName

    ,person.last_name as LastName

    ,address.street1 as Address1

    ,address.street2 as Address2

    ,city.name as City

    From person

    left join [address] on address.person_id = person.person_id

    left join city on city.person_id = person.person_id

    --I am looking for below result set

    (row_id) (view_name) (view_column_name) (table_name) (table_col_name)

    ------------------------------------------------------------------------

    1 individual FirstName person first_name

    2 individual LastName person last_name

    3 individual Address1 address street1

    4 individual Address2 address street2

    5 individual City city name

Viewing 3 posts - 1 through 2 (of 2 total)

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