Solved

Finding a Field

Posted on 2011-02-21
3
474 Views
Last Modified: 2013-11-05
I'm sure this is a long shot, but I'll ask anyway.

I have a database that contains roughly 400 tables, and probably a similar amount of views.

Some where in all that, there is a field I'm looking for with a name that contains the word "Applied" (Might be Applied_Total or Applied_Sum or other some such).  Now, I could take the next two or three hours and look at the field listing of each table and view and try and find out which one(s) I'm looking for, but that is way too tedius.

Is there any way to find out which tables (and maybe views) which contain the fields which contain the word "Applied"?
0
Comment
Question by:Clif
3 Comments
 
LVL 9

Accepted Solution

by:
s_chilkury earned 500 total points
ID: 34945448
SELECT table_name=sysobjects.name,
         column_name=syscolumns.name,
         datatype=systypes.name,
         length=syscolumns.length
    FROM sysobjects
    JOIN syscolumns ON sysobjects.id = syscolumns.id
    JOIN systypes ON syscolumns.xtype=systypes.xtype
   WHERE sysobjects.xtype='U'
            AND syscolumns.name LIKE '%Applied%'
ORDER BY sysobjects.name,syscolumns.colid

OR

SELECT name FROM sysobjects WHERE id IN ( SELECT id FROM syscolumns WHERE name LIKE '%Applied%' ) ORDER BY name
0
 
LVL 32

Expert Comment

by:ewangoya
ID: 34945531

select sys.objects.name as [Table name], sys.columns.name as [Column]
from sys.columns
inner join sys.objects ON sys.objects.object_id = sys.columns.object_id
where type = 'U'
and sys.columns.name like '%Applied%'
0
 
LVL 10

Author Closing Comment

by:Clif
ID: 34945647
That was perfect.

To tell you the truth, I was sure I was going to get a reply that it couln't be done.

Thank.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question