Solved

SQL Database Names

Posted on 2007-03-27
5
184 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

821 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