Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 55
  • Last Modified:

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

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
jamesmetcalf74
Asked:
jamesmetcalf74
  • 2
2 Solutions
 
Scott PletcherSenior DBACommented:
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
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
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
 
Scott PletcherSenior DBACommented:
Correction:

WHERE name ...

Should be:

WHERE c.name ...
0
 
jamesmetcalf74Author Commented:
Thanks you guys.
sorry for the late response.
you got me squared away
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now