How To Find a Column or a Word in Whole Database in SQL Server

Find a Column Name in Whole Database

Sometimes you may want to search for a column name in whole database. Instead of looking all the columns of all the tables one by one, you can use one of the following scripts.

For example, suppose that we search a column named “phone” in whole database.

Find a Word in Whole Database

Or, you may want to search for a text in the entire database. You can use the following stored procedure for this.

After you create the Stored procedure, you can run it as follows. In large databases, you must be careful when running this query. Because all the data in the database will be scanned.

Lest execute stored procedure on TestDB for searching “Nurullah” in the whole database.

The query will return all Nurullah values in the database as below.

 

dbtut
Author: dbtut

We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.

Leave a Reply

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