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
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 script to return user databases

Author  Topic 

rb1373
Yak Posting Veteran

93 Posts

Posted - 2004-11-16 : 10:47:30
Does anyone know how to return user databases?

On a development server, I would like to run a script nightly to shrink the databases, set the recovery modes to simple, etc.

Thanks!

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-11-16 : 10:52:36
SELECT name FROM master..sysdatabases WHERE name NOT IN ('master', 'model', 'msdb', 'tempdb')

You may have additional system DB's if you have replication on that server. Just add those names to the IN list.
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-11-16 : 20:39:49
select [name] from master..sysdatabases where id>4 and name<>'distribution'

-which is the same as robvolk, just add 'distribution' (replication)

--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -