Find All Tables Containing Column With Specified Column Name – MS SQL Server

Introduction

In this article, we will discuss how to get the list of table names that contain specific columns. Sometimes we may need to find the table names which contain similar column names or we may know the column name but, we may not remember the table name. By using a simple query we can find the table name.

Using INFORMATION_SCHEMA.COLUMNS Table

Syntax
SELECT      COLUMN_NAME AS [Column Name]
            ,TABLE_NAME AS  [Table Name]
FROM        INFORMATION_SCHEMA.COLUMNS
WHERE       COLUMN_NAME LIKE '%Column Name%'
ORDER BY    [Table Name]
Sample Query
SELECT      COLUMN_NAME AS [Column Name]
            ,TABLE_NAME AS  [Table Name]
FROM        INFORMATION_SCHEMA.COLUMNS
WHERE       COLUMN_NAME LIKE '%Name%'
ORDER BY    [Table Name]
Fig. 1 List of Tables that Contains Column as Name

Conclusion

In this simple article, we discussed how to get the list of table names based on the column name. Hope this simple tip was useful. Please share your feedback in the comment section. We will discuss more in upcoming articles.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Website Built with WordPress.com.

Up ↑

%d bloggers like this: