Solved

search query to find column name

Posted on 2010-08-24
3
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

695 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