Search the database for a certain column

0 comments
If you are working on a big database (or a database that you don't know very well) and don't waste time opening up all the tables to find out where a certain column is, just run the following SQL statement against the database:
SELECT t.name AS table_name,
       SCHEMA_NAME(schema_id) AS schema_name,
       c.name AS column_name
FROM sys.tables AS t
     INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE '%validity_date_start%'
ORDER BY schema_name,
         table_name;
SQL

Comments


Leave a Comment