Link to home
Start Free TrialLog in
Avatar of cfgunnyNsite
cfgunnyNsiteFlag for United States of America

asked on

SQL 2008 default database detached. Can't login.

ISSUE: SQL Server 2008 database has been detached. All logins had this database as default database. Now, all users can log into the server and can run queries on the other databases on the same server, but none of the logins can perform any actions from Management Studio, i.e., backup, restore, view or edit database or login properties, etc.
The error displayed is:
"Cannot open user default database. Login Failed.
  Login failed for user 'sa'. Microsoft SQL Server, Error: 4064"

The server is SQL Server 2008 running on a Windows XP development box.
The databases are all SQL Server 2000 compatible.

REQUEST: Is there a way to regain access at some level so we can re-attach the database? Possibly change the login's default database via TSQL query?

ASKER CERTIFIED SOLUTION
Avatar of beta911
beta911

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cfgunnyNsite

ASKER

beta911:,
Thanks! I should have thought of that. Been under a LOT of pressure on this project and it shows. Boy, do I feel stupid.
Actually, I had to tweak your suggestion a bit. If I log into another database as 'sa', it will still try to create a new connection as 'sa' for each menu command I attempt. It still attempts with the default database and erorrs out. But you did get me going. While logged into 'master', I created another user, via script, with sysadmin privilages and 'master' as the default database. I disconnected and reconnected as the new user and I have full access. I then changed the default database for all the other users, re-attached the original database and I'm in business, again.

Thanks, again.
Points awarded for knowledge and patience.
Solution may have worked on earlier version. Tweaked solution to work on GUI.