Hi All
I have a SQL Server 2005 server and I was wanting to determine all of the
user databases and I was wondering if there was a better way to do this
instead of the following script:
select name
from master.sys.databases
where name not in ('mater', 'tempdb', 'msdb', 'model')
Thanks
If these are the only 4 db's that you want to eliminate, then you could also
query based on database_id, and then it wouldn't matter if you don't spell
one of the database names correctly. :-) You also don't need a 3-part name
when you use the new metadata views.
SELECT name FROM sys.databases
WHERE database_id > 4
If you set up replication, some servers will get a distribution database,
and you may want to eliminate that one also.
HTH
Kalen Delaney, SQL Server MVP
http://sqlblog.com
"David" <David@.discussions.microsoft.com> wrote in message
news:7B789F7B-702A-4109-9FEB-D8E6F27A4FE5@.microsoft.com...
> Hi All
> I have a SQL Server 2005 server and I was wanting to determine all of the
> user databases and I was wondering if there was a better way to do this
> instead of the following script:
> select name
> from master.sys.databases
> where name not in ('mater', 'tempdb', 'msdb', 'model')
> Thanks
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment