Solved

SQL Database Names

Posted on 2007-03-27
5
164 Views
Last Modified: 2010-03-19
Visual C# Windows Application.

Is it possible and if so how do you query the SQL Database Names when you have the Server Name and Instance?

For instance:  I know the server name is SQLSERVER1  and the instance is SQLEXPRESS.  How do I get a list of the 3 or 4 databases on that server: master, mydatabase, etc.

Thanks for the help.
0
Comment
Question by:sneeri_c
5 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
Comment Utility
you need access to the master database...

select * from master..sysdatabases
0
 
LVL 11

Expert Comment

by:Ved Prakash Agrawal
Comment Utility
Used SQL-DMO which provide extensibly feature to manage complete server.
0
 
LVL 11

Expert Comment

by:Ved Prakash Agrawal
Comment Utility
http://www.csharphelp.com/archives2/archive342.html

tried to look this link may be you will get u r answer .......cheers!!!!!!!!!!

0
 
LVL 18

Expert Comment

by:Sham Haque
Comment Utility
a wise expert once said to use master views rather than tables wherever poss:

SELECT [CATALOG_NAME]
FROM [master].[INFORMATION_SCHEMA].[SCHEMATA]
0
 
LVL 1

Accepted Solution

by:
google-web-info earned 500 total points
Comment Utility
Hey Sneeri_C,

Because the code is too long, so i uploaded an demo and source code here: http://google-web.info/download/sqldatabases.zip

You can test the demo and read out the source code easily,

Grz,
Joesy
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

762 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

8 Experts available now in Live!

Get 1:1 Help Now