Solved

SQL Database Names

Posted on 2007-03-27
5
176 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
ID: 18799446
you need access to the master database...

select * from master..sysdatabases
0
 
LVL 11

Expert Comment

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

Expert Comment

by:Ved Prakash Agrawal
ID: 18799457
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
ID: 18799522
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
ID: 18799730
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

867 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

18 Experts available now in Live!

Get 1:1 Help Now