views:

241

answers:

2

I know that so far (until MSSQL 2005 at least), system databases are master, model, msdb and tempdb.

Thing is, as far as I can tell, this is not guaranteed to be preserved in the future. And neither the sys.databases view nor the sys.sysdatabases view tell me if a database is considered as a system database.

Is there someplace where this information (whether a database is considered a system database or not) can be obtained?

A: 

no there's no such option AFAIK. i guess you could check the id the sys.databases.owner_sid = 0x01.

i don't think you have to worry about MS changing the system db names. if they did theat you wouldn't have to worry about it for at least 20 years :)

Mladen Prajdic
A: 

You can rely on the DB_ID() function <= 4

You'd have to work very hard to change this...

gbn
DB_ID() returns the dbid column on sys.sysdatabases, right?
Vinko Vrsalovic
@Vinko: yes, it does
gbn