Home Forums SQL Server 2005 T-SQL (SS2K5) stored procedure---finding all tables that contain a specific column RE: stored procedure---finding all tables that contain a specific column

  • try it like this:

    CREATE PROC spWhichTable

    @ColumnName varchar(50)

    AS

    SELECT o.name as [Table]

    , c.name as [Column]

    FROM sys.tables o

    JOIN sys.columns c ON o.object_id = c.object_id

    WHERE c.name = '@ColumnName'

    AND o.type = 'U'

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]