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
Solved

search query to find column name

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delete the first occurence of a duplicate row in sql 5 38
SQL DATEADD 10 70
Amazon RDS migrate to SQL Server 3 24
Query for timesheet application 3 17
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 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