Solved

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

Posted on 2016-10-12
4
39 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:
ScottPletcher 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:ScottPletcher
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
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.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

920 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

15 Experts available now in Live!

Get 1:1 Help Now