Here's a way in 2000 using a UDF (easy enough to convert to a proc in SQL 7). It's not pretty but it works, I thought there would be a DATABASEPROPERTX function but it appears not - having said that,it's not exactly the end of the world to hard code the names (not forgetting replication). I'd actually guess that SQLDMO has got the system dbnames hardcoded anyway
- I will try and find outselect CATALOG_NAMEfrom INFORMATION_SCHEMA.SCHEMATAwhere dbo.IsSystemDB(CATALOG_NAME)=0 /* 1 = System , 0 =User */
CREATE FUNCTION dbo.IsSystemDB(@dbname sysname)RETURNS INT /* 1 = System , 0 = User */ASBEGINDECLARE @hr intDECLARE @sql intDECLARE @db intDECLARE @status intDECLARE @system varchar(5)DECLARE @dbcmd varchar(200)SET @dbcmd = 'Databases("'+@dbname+'").SystemObject'EXEC @hr = sp_OACreate 'SQLDMO.SQLServer', @sql OUTPUTIF @hr<>0 EXEC sp_OAGetErrorInfo @sqlEXEC @hr = sp_OASetProperty @sql ,'LoginSecure','True'IF @hr<>0 EXEC sp_OAGetErrorInfo @sqlEXEC @hr = sp_OAMethod @sql,'Connect',NULL,@@SERVERNAMEIF @hr<>0 EXEC sp_OAGetErrorInfo @sqlEXEC @hr = sp_OAGetProperty @sql, @dbcmd, @system OUTPUTIF @hr<>0 EXEC sp_OAGetErrorInfo @sqlEXEC @hr = sp_OAMethod @sql,'DisConnect',NULLIF @hr<>0 EXEC sp_OAGetErrorInfo @sqlEXEC @hr=sp_OADestroy @sqlIF @hr<>0 EXEC sp_OAGetErrorInfo @sqlSELECT @status = CASE WHEN UPPER(@system)='TRUE' THEN 1 ELSE 0 ENDRETURN @statusENDHTHJasper Smith