Solved

search query to find column name

Posted on 2010-08-24
3
267 Views
Last Modified: 2012-05-10
I use to have a query that would search for an existing column and then return the table name.

however, I'm having a hard time finding it, can anyone help me re-create?

0
Comment
Question by:sl1nger
3 Comments
 
LVL 12

Assisted Solution

by:mcv22
mcv22 earned 200 total points
ID: 33516197
In the database that contains the table,

select table_name from information_schema.columns
where column_name = 'colName'

select table_name from information_schema.columns
where column_name LIKE '%colName%'
0
 
LVL 7

Accepted Solution

by:
mquiroz earned 300 total points
ID: 33516312
something like this:

select
t2.name
from
syscolumns t1 inner join sysobjects t2 on t1.id = t2.id
where
t1.name like '%olumnname%'
0
 
LVL 9

Expert Comment

by:sureshbabukrish
ID: 33519270
select
o.name as tableName,
c.name as ColumnName,
o.type as ObjectType,
u.name as SchemaName
from syscolumns c
inner join sysobjects o
on o.id=c.id
and o.xtype = 'U'
inner join sysusers u
on u.uid= o.uid
where
c.name like '%RANGE%'
and o.name = 'tablename'
ORDER BY 1,2
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now