T-SQL Find column name in database

My Learning: Log in Learning Report [Log in]

Remove Ads or Log in
Remove Ads or Log in
+0  |  -0
Very often you need to use a specific field from sql server database table. The problem is how to find column name in database in any table using tsql? The answer is use information_schema and more precisely information_schema.columns

This is easy. Just open new query select the database from the drop down box you want to search and type

select *
from information_schema.COLUMNS
where column_name like '%name%'

The sql query above will show you every column that contains value ‘name’. If you have many results you can eliminate them by filtering it using the available columns. Usually table name field can be used to limit the results for instance if you are after name but for an employee you could try:

select *
from information_schema.COLUMNS
where column_name like '%name%' and table_name like '%emp%'

Remove Ads or Log in

We need you!

Time of free websites that are supported by ads only is over, due to increasing use of ad blocking.

Our website would die probably within a year; as there is no point investing free time and later on own money in something that is doomed.

Our only hope to survive (without any ads) is to ask our visitors like yourself to support it by becoming a member.

We know it's only going to be a tiny % of visitors who will do that but we hope that will be enough to keep our website for free and within a year switch off all ads. (54% page ads are switched off already for visitors from low income countries and 15% video ads are switched off for everyone).

Become a regular supporter (with benefits)
or make a one-off donation

Visitor Voting

Visitor comment (we like):
"I like you both, you read Dale Carnagie, you want what most of us want and you are trying to do something useful for all! You are already successful! Blessings!"
Add comment (no email required).

Add Comment
No data was returned.