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
2008-09-29 05:51:08
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
2009-12-31 14:48:05
+4
A:
To exclude system databases:
SELECT [name]
FROM master.dbo.sysdatabases
WHERE dbid > 6
GilM
2008-09-29 06:28:14