must be an error in copy and paste - you are missing a '.' - it should read master..sysdatabases
this code is compatible with all versions of sql from sql2000, you could also use master.sys.databases
---------------------------------------------------------------------