Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 how to retrieve one sql server database names?

Author  Topic 

mgkind
Starting Member

8 Posts

Posted - 2004-09-18 : 08:23:15
I would be very pleased if I know how can I retrieve the database names of one sql server by query?
I want to use it programmatically!
Is there any query for getting the database name of one sql server 2000 's serve?

thanks
mgkind

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-09-18 : 08:49:45
SELECT name FROM master..sysdatabases
Go to Top of Page

mgkind
Starting Member

8 Posts

Posted - 2004-09-19 : 04:37:05
tanks robvolk
and below is the other codes for getting table list of one db:

SELECT name FROM sysobjects
where type='U'
order by name

Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-09-20 : 07:04:32
or use select table_name from information_schema.tables
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-09-20 : 07:15:38
I recommend the use of the information_schema views:
SELECT CATALOG_NAME FROM INFORMATION_SCHEMA.SCHEMATA
Also see:
SELECT DB_NAME(), DB_ID()

rockmoose
/* Chaos is the nature of things...Order is a lesser state of chaos */
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-09-21 : 00:26:30
quote:
Originally posted by jen

or use select table_name from information_schema.tables



--edit

sorry didn't read the question clearly, duh, what was i thinking?
Go to Top of Page
   

- Advertisement -