Changing the "default database" opton in login
You can use sys.server_principals to find default database and alter login to change it. 

SELECT name,
       default_database_name,
       'alter login ['+name+'] with default_database=master;'
FROM sys.server_principals
WHERE default_database_name &lt;&gt; 'master';