How do you identify system and user databases programatically? How do you hide the "master" database from the user when running an installer? Use these scripts to either list system or user databases as requried.
--********************************************************* --WARNING: --These queries are provided "as-is" and without warranty --The author, BeyondRelational.com and Microsoft are not --responsible for damage caused by misuse of this query --********************************************************* --Provides a list of system databases SELECT sdb.database_id, sdb.name FROM sys.databases sdb WHERE CAST((CASE WHEN SUBSTRING(sdb.name,0,14) IN ('master','msdb','model','tempdb','ReportServer$') THEN 1 ELSE sdb.is_distributor END) AS BIT) = 1 --Provides a list of user databases select sdb.database_id, sdb.name from sys.databases sdb WHERE CAST((CASE WHEN SUBSTRING(sdb.name,0,14) IN ('master','msdb','model','tempdb','ReportServer$') THEN 1 ELSE sdb.is_distributor END) AS BIT) = 0