SQL Server: Search For Column In a Database

So let’s say you have a SQL Server db that contains 100 tables. You want to know which of these 100 tables contains a column of a certain name without poring through all 100 manually.

Use this syntax:

SELECT * FROM sysobjects
WHERE id IN ( SELECT id FROM syscolumns WHERE name = 'column_name_here' )

This only seems to search the db in current scope, not all the db’s in your particular SQL Server DBMS.


Tags: , ,

 
 
 

Leave a Reply