Find Tables with a Column Name In a DataBase

kgovindarao523-21772
Posted by kgovindarao523-21772 under Sql Server category on | Points: 40 | Views : 528
Hi,

I came up with scenario which is to find out all tables names that contains a specific column.

Here is the code.
SELECT DISTINCT SCHEMA_NAME(schema_id) + '.' + t.name AS 'Table Name'
FROM sys.tables t
     INNER JOIN sys.columns c
        ON c.object_id = t.object_id
WHERE c.name like '%YOURColumn%'
ORDER BY 'Table Name'

Comments or Responses

Login to post response