Automations

Search All Tables For A Particular Table Name Or Column Name

Here’s a simple ( and probably the most common ) way to search across all your tables, and columns within those tables; if you are looking for a particular name either on the table side, or the column side. Use the following 2 tables to make a basic query. You can do this in every database.

Information_Schema.Tables
Information_Schema.Columns

They are both self explanatory, but the .Columns is more comprehensive. Anyway; on with the logic.

use [MyDatabase]
select
table_schema
, table_name
, column_name
from
information_schema.columns
where
table_name like '%Something%'
order by
table_name, column_name asc

Easy.

Advertisements

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 )

Google+ photo

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

Connecting to %s