June 4, 2008 at 6:35 pm
Goal: to get list of all databases except system databases
the way i am doing is
SELECT [name]
FROM sys.databases
This query returns all databases including system databases.
Is there any way to get database list instead of using underlying query
SELECT [name] FROM sys.databases
where name not in ('master', 'tempdb', 'model', 'msdb')
June 4, 2008 at 6:53 pm
How about this?
select * from sys.databases where database_id > 4
June 4, 2008 at 9:18 pm
select * from sys.databases where database_id > 4
do these four system databases would always fall under database id 1-4? if so, then i can consider this query too. By mentioning system database names, i am sure that i'll not get back names of these databases in any case.
June 5, 2008 at 8:19 pm
Yes. Either one works fine up to version SQL2008. Unless system databases have changes after SQL2008.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply