PRB: "Cannot Open Default Database <ID>. Using Master Instead"ID: Q196076
|
When attempting to connect to Microsoft SQL Server, you may see the following message:
When attempting to login using Query Analyzer, the following error occurs:Cannot open user default database <ID>. Using master instead.
If the client is using an ODBC or OLEDB-based connection, it will not be allowed to log in to SQL Server as the message suggests. If the connection is DB-Library-based, the client will be able to successfully log in to SQL Server and be in the master database.Msg 4062 Severity 11 Cannot open user default database '%.*ls'. Using master database instead.
This error may occur for either of the following reasons:
To work around this problem, do either of the following:
use <database name>
go
exec sp_grantdbaccess <login name>
go
NOTE: Do not specify the name_in_db when running sp_grantdbaccess
because the name the user is known by in the database is whatever name
was specified in the sp_addrolemember call. Also, SQL Enterprise Manager
will show the login as already having been granted database access, so
you will need to run the sp_grantdbaccess procedure to resolve this
problem.
use master
go
sp_defaultdb <login name>, <new default database name>
go
If the login unable connect is sa, connect to SQL Server using command-line
ISQL. Because ISQL uses DB-Library, you will be able to successfully
connect and will be in the master database.
To use ISQL, perform the following steps:
isql -Usa -P<sa password> -S<server name>
Additional query words:
prodsql SEM can't connect failed GUI OLE DB dblib
db-lib open connectivity
Keywords :
Version : winnt:7.0
Platform : winnt
Issue type : kbprb
Last Reviewed: August 12, 1999