Solved

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

Posted on 2016-10-12
4
31 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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.
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…
Viewers will learn how the fundamental information of how to create a table.

758 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

22 Experts available now in Live!

Get 1:1 Help Now