TechAid24

Your Technical Consultant

How to Search for a Column Name Across All Tables in SQL Server

Posted on by Anonymous Guest 1 minute read

In this post, we want to discuss all tables containing columns with the specified names in SQL Server. Before we get started, if you want to know the necessity of Store Procedure, please go through the following article: Why do we need use Stored Procedure?

Say the column name is “MyColumnName”. The SQL is as bellow

SELECT c.name AS ColName, t.name AS TableName FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE c.name LIKE '%MyColumnName%'

For searching in Tables and View in the same DB

SELECT COLUMN_NAME, TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS 
WHERE COLUMN_NAME LIKE '%MyColumnName%'
all tables containing column sql server

Tags:

Anonymous Guest

An anonymous author is a writer who conceals their true identity when publishing content, often for privacy, security, or confidentiality reasons. This approach is often used in technical articles to focus on the information being presented rather than the author's personal identity.

2 comments

  1. Hiya very cool site!! Man .. Beautiful .. Amazing .. I’ll bookmark your website and take the feeds also? I am satisfied to seek out a lot of useful information right here in the put up, we need work out extra techniques on this regard, thank you for sharing. . . . . .|

Leave a Reply

Your email address will not be published. Required fields are marked *