Solved

find all columns in a database with name like...

Posted on 2016-10-12
4
41 Views
Last Modified: 2016-11-03
Hey guys-
is there a way to query a whole database and find all the columns (regardless of what table it lies in)
that has a name like optionskey?
0
Comment
Question by:jamesmetcalf74
  • 2
4 Comments
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 250 total points
ID: 41840904
Something like this:

SELECT ...
FROM sys.columns c
INNER JOIN sys.tables t ON t.object_id = c.object_id
WHERE name LIKE '%option%key%' /*adjust as needed to get specifically what you want*//
0
 
LVL 65

Assisted Solution

by:Jim Horn
Jim Horn earned 250 total points
ID: 41840905
Sure..
SELECT t.name as table_name, c.name as column_name
FROM sys.tables t
   JOIN sys.columns c ON t.object_id = c.object_id
WHERE c.name LIKE '%optionskey%'

Open in new window

0
 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 41840910
Correction:

WHERE name ...

Should be:

WHERE c.name ...
0
 

Author Comment

by:jamesmetcalf74
ID: 41850166
Thanks you guys.
sorry for the late response.
you got me squared away
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
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…

816 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

13 Experts available now in Live!

Get 1:1 Help Now