Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Check for existence of a field across multiple tables 1

Status
Not open for further replies.

timgill

IS-IT--Management
Feb 9, 2001
30
0
0
US
Let's say you have a database that has 100 tables in it. I want to be able to search across all tables and return a list of all tables where a specific field exists.

Any ideas on a nice, clean way to do this?

Tim Gill
Gill Consulting
 
Tim, try this...

declare @myfield varchar(50)
set @myfield = 'i_account_id' -- the specific field
select o.name as tablename, c.name as colname
from syscolumns c, sysobjects o
where c.id = o.id and c.name = @myfield

Hope this helps..

Maingel

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top