Thursday, November 25, 2010

[SQL Server] Search Table using Column Name

In high pressure professional environment, we sometime require to know which tables have some xyz column, and its quite tedious to search entire database. Here is the magic-wand query for this problem:

SELECT * FROM sys.tables WHERE object_id IN
(SELECT object_id FROM sys.columns WHERE name LIKE '%<column-name>%')

Amazing... isn't it! :)

No comments:

Post a Comment