I agree. You'd expect the specifically-chosen (?) "featured script" to be something at least moderately good/useful, but most often they are not.
As for this code, I would suggest simply:
SELECT CASE WHEN DB_ID (@dbname) IS NULL THEN 'NO' ELSE 'YES' END
SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.