Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Posts
    1

    Question Unanswered: how to enumerate all table in db???

    how to enumerate all table with a column name in sqlserver db???

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    This returns all objects with a given column name:

    --------------------------------------------
    declare @SearchColumn varchar(50)
    set @SearchColumn = 'Database_ID'

    select sysobjects.name as ObjectName,
    sysobjects.xtype as ObjectType
    from sysobjects
    inner join syscolumns on sysobjects.id = syscolumns.id
    where syscolumns.name = @SearchColumn
    --------------------------------------------

    If you want just tables, filter for sysobjects.xtype = 'U'
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •