tags:

views:

4540

answers:

2

how can i get the list of available databases in a SQL server? im planning to make a list of that in combobox in vb.net. tnx.

+14  A: 
SELECT name
FROM master..sysdatabases

or if you prefer

EXEC sp_databases
Ben Hoffstein
Thumbs up for "EXEC sp_databases". The reason for this is that "sysdatabases" does not actually exist in SQL 2005 and 2008. It is renamed to "sys.databases". Cheers.
Gia
+4  A: 

To exclude system databases:

SELECT [name]
FROM master.dbo.sysdatabases
WHERE dbid > 6
GilM