Solved

search query to find column name

Posted on 2010-08-24
3
269 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

772 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