Finding a column name in a table that you don’t know the table name

  • Hi all,

     

    I have the following column name that I need to know which table owns it. SC_BL_ADAPT

    Is there way to find it either with SQL script or from SQL Server Enterprise Management?

     

     

     

     

     

    Thanks in advance,

     

     

    Abrahim

  • As you wrote under notification services, I assume you're on sql 2005.

    select

    st.[name] as TableName,sc.[name] as ColumnName, ss.[name] as SchemaName from sys.columns sc

    join

    sys.tables st on sc.[object_id]=st.[object_id]

    join

    sys.schemas ss on st.[schema_id]=ss.[schema_id]

    where

    sc.[name]='SC_BL_ADAPT'

    For sql 2000 you can use INFORMATION_SCHEMA.

     

  • Michaela,

    Thanks for the help,

     

    Abrahim

  • I found this script that it finds the table's name.

    SELECT name FROM sysobjects WHERE id IN ( SELECT id FROM syscolumns WHERE name = 'SC_BL_ADAPT' )

     

    Abrahim

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

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