Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to search a coulmn in a databse.

Author  Topic 

qingchengottawa
Starting Member

7 Posts

Posted - 2006-10-12 : 09:40:08
I would like to search a column name in all the tables in a database. Is there a way to do it?

Thanks,

Qing

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2006-10-12 : 09:42:33
[code]SELECT
table_name,
column_name
FROM dbname.information_schema.columns
WHERE
column_name LIKE '%searchterm%'[/code]

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-12 : 09:42:50
Yes. You can create a view and union all tables or you can turn to dynamic sql.
There are a lot of topics for that here at SQLTeam. Feel free to search.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2006-10-12 : 09:50:39
Ah...I was so fascinated by the information_schema views that I thought that was what he was looking for

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-13 : 10:16:41
quote:
Originally posted by Peso

Yes. You can create a view and union all tables or you can turn to dynamic sql.
There are a lot of topics for that here at SQLTeam. Feel free to search.


Peter Larsson
Helsingborg, Sweden


Did you mean searching a value in all columns of all tables?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -