SQL Tips by Namwar Rizvi

January 8, 2009

Search all columns of all tables for a particular value

Filed under: How To,Object Search,tips,TSQL — namwar @ 7:30 PM
Tags: , , , , ,

Several times I have came across with the question that how can I search all columns of all tables in a SQL Server database for a particular value. Unfortunately, you can not perform this query directly by any already provided system table or object. 

There are some fundamental points to remember:

 

  1. You have to iterate the list of tables and for each table you have to iterate each column and perform an exist query against it. 
  2. You will need three types of queries due to the data types i.e. string, number and date and time.
I have found an excellent article here which provides a good explanation along with the necessary sql script. I would recommend every reader to read this article.

 

3 Comments »

  1. [...] 2008, Search columns — namwar @ 8:50 am Tags: SSMS, Tools In my one of earlier articles here I wrote about a way to find any value in any database column. Today, I found a great free tool, [...]

    Pingback by Search anything in your Database schema right from SSMS « SQL Tips by Namwar Rizvi — March 29, 2010 @ 8:50 AM | Reply

  2. [...] my one of earlier articles here I wrote about a way to find any value in any database column. Today, I found a great free tool, [...]

    Pingback by Search anything in your Database schema right from SSMS — March 29, 2010 @ 8:54 AM | Reply

  3. I wanted create search system from sql data. How retrive data from multipal table without join. Because No common field in table. I have Many table.

    Please help me.

    Comment by om prakash — March 30, 2010 @ 6:39 AM | Reply


RSS feed for comments on this post. TrackBack URI

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

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.