DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Find A Column By Name On MS SQL Server

01.15.2010
| 7312 views |
  • submit to reddit
        // If you need to find the location and owning table of a column on a large database, this is a very simple and quick search query.
// By default it's looking only at user tables (type 'U').

SELECT o.name,c.name FROM sysobjects o
inner join syscolumns c
on o.id = c.id
WHERE o.type = 'U' and c.name LIKE '%whatever%'