Welcome to MSDN Blogs Sign in | Join | Help
Get all system databases of a server

The easiest way for querying all system databases of a server is to assume that databases create by a user come with a database_id >= 5 in sys.databases. But the problem is that distribution databsaes will not be kept into this consideration. Therefore SMO does the following behind the scenes (bioled down to the relevants facts) while querying the objectmodel for the property Server.Database[n].IsSystemObject

SELECT
dtb.name AS [Name],
CAST(case when dtb.name in ('master','model','msdb','tempdb') then 1 else dtb.is_distributor end AS bit) AS [IsSystemObject]
FROM
master.sys.databases AS dtb

-Jens

Posted: Wednesday, July 16, 2008 11:06 AM by Jens K. Suessmeyer
Filed under: , ,
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker