Determine all tables where fieldname exists

  • Is there a table in SQLSERVER that I can query that will tell me all tables that use a particular field?

  • you mean something like

    
    
    SELECT
    table_schema, table_name
    FROM
    information_schema.columns
    WHERE
    column_name = 'MsgDateReceived'

    or

    SELECT
    s2.name
    FROM
    dbo.syscolumns s1
    JOIN
    dbo.sysobjects s2
    ON
    s1.id = s2.id
    WHERE
    s1.NAME='MsgDateReceived'

    or

    SELECT
    table_schema, table_name
    FROM
    information_schema.columns
    WHERE
    column_name like 'MsgDateReceived'
    AND
    objectproperty(object_id(table_name), 'IsUserTable') = 1
    ORDER BY
    column_name

    Frank

    http://www.insidesql.de

    http://www.familienzirkus.de

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

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

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