When connecting to computer running Microsoft SQL Server,if a login database is not specified, the users default database is used. However, if the default database is unavailable at the time of the connection, the error message 4062 or error message 4064 may display.
The user default database is unavailable at the time of connection may be due to one or more conditions:
Is in suspect mode.
No longer exists.
Is in single user mode and the only available connection is already being used by someone else or by something else.
Has been detached.
Has been set to the RESTRICTED_USER state.
Is set to emergency status.
Does not have the login account mapped to a user or the user has been denied access.
Is part of a database mirror.
Additionally, the login account may be a member of multiple groups and the default database for one of those groups is unavailable at the time of connection.
Verify thatthe BUILTIN/Administrators account/group is utilizingthe master database as the default
SQL Server 2005
You can use the sqlcmd utility to change the default database in SQL Server 2005. To do this, follow these steps:
1. Click Start, click Run, type cmd, and then press ENTER.
2. Use one of the following methods, depending on the kind of authentication that the SQL Server login uses: If the SQL Server login uses Microsoft Windows authentication to connect to the instance, type the following at the command prompt, and then press ENTER:
sqlcmd E -S InstanceName d master
If the SQL Server login uses SQL Server authentication to connect to the instance, type the following at the command prompt, and then press ENTER:
sqlcmd -S InstanceName -d master -U SQLLogin -P Password
Note: InstanceName is a placeholder for the name of the SQL Server 2005 instance to which you are connecting. SQLLogin is a placeholder for the SQL Server login whose default database has been dropped. Password is a placeholder for the SQL Server login password.
SQL Server 2000 and SQL Server 7.0
You can use the osql utility to change the default database in SQL Server 2000 and in SQL Server 7.0. To do this, follow these steps:
1. At a command prompt, type the following and then press ENTER:
2. At the osql prompt, type the following and then press ENTER:
1>sp_defaultdb users_login, master
3. At the second prompt, type the following and then press ENTER:
For additional information: http://support.microsoft.com/kb/307864/en-us