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
 General SQL Server Forums
 New to SQL Server Programming
 list all databases present on a particular server.

Author  Topic 

raaj
Posting Yak Master

129 Posts

Posted - 2008-12-14 : 23:41:49
Hi Guys,
I would like to know : How to write a query to list all the databases present on a particular server????

Any suggestions????

Thanks.....

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2008-12-14 : 23:55:11
select * from sys.databases
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-15 : 00:02:50
if sql 2000 or earlier use
select * from sysdatabases
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-12-15 : 00:11:13
Check out sp_databases too as it provides a little extra detail.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

raaj
Posting Yak Master

129 Posts

Posted - 2008-12-15 : 00:21:58
Hi guys,
Thnx for your replies........

Raaj...


Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-12-15 : 00:34:16
You're welcome.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

onlyforme
Starting Member

25 Posts

Posted - 2008-12-15 : 01:30:24
select * from sys.tables where type='U'
Thanks.....
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-15 : 01:34:38
quote:
Originally posted by onlyforme

select * from sys.tables where type='U'
Thanks.....



Are you reading questions before posting? OP asked for listing database details.How do you think sys.tables provide database info?
Go to Top of Page

JamesRyan
Starting Member

18 Posts

Posted - 2008-12-15 : 09:49:51
SQL 2005:

SELECT * FROM sys.databases


James Ryan
www.sqlhowto.co.uk
Go to Top of Page

NeilG
Aged Yak Warrior

530 Posts

Posted - 2008-12-15 : 10:40:22
you can also try sp_helpdb
Go to Top of Page
   

- Advertisement -