Search for column name across all tables


Here is another sql script I got from my friend David McCollough that will allow you to search all tables for a specific field name.

Just set the @ColumnName variable and let ‘er rip.


DECLARE @ColumnName       varchar(1000)

SET @ColumnName = 'PlayerId'

    select as TableName,
  as [ColumnName]
      from sysobjects o 
inner join syscolumns c on =
      where o.type = 'u' and = @ColumnName       
   Order by TableName
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }
Technorati Tags:

posted @ Monday, December 7, 2009 7:57 AM


Comments on this entry:

No comments posted yet.

Your comment:

 (will not be displayed)

Please add 4 and 5 and type the answer here:

Live Comment Preview: