Friday, October 16, 2009

Finding Table Columns in SQL Server

Somestimes you need to know all the tables that have a specific column name.  Use this query:

select o.name
from sys.all_objects o, sys.all_columns c
where o.object_id = c.object_id
and o.type = 'U'
and lower(c.name) = 'thecolumnnameyouwant'
 
type = 'U' is for user tables

No comments:

Post a Comment