• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

Gather list of databases

Is there a way to obtain a list of database names programmatically that follow a certain naming convention?


For example, I want to obtain all databases that are named GHH_QA_CDR_<whatever>

db names
0
Tom Knowlton
Asked:
Tom Knowlton
1 Solution
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Give this T-SQL a whirl..
SELECT name 
FROM sys.databases
WHERE LEFT(name, 11) = 'GHH_QA_CDR_'   
ORDER BY name

Open in new window

0
 
Tom KnowltonWeb developerAuthor Commented:
Yep!
0

Featured Post

Will You Be GDPR Compliant by 5/28/2018?

GDPR? That's a regulation for the European Union. But, if you collect data from customers or employees within the EU, then you need to know about GDPR and make sure your organization is compliant by May 2018. Check out our preparation checklist to make sure you're on track today!

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