Geeks With Blogs

Tim Huffam Dotting the I and crossing the T of I.T.
This error (Cannot Open User Default Database, Login Failed Microsoft SQL Server, Error 4064), occurs when you try to connect to a SQL Server 2005 server where the default database for your user has been dropped.  Unfortuntely this occurs in Microsoft SQL Server Studio too - which means you cannot use it to resolve the issue (ie change the default database assigned to your login).
 
However you can resolve this using ye-olde command prompt...
 
1) At the command prompt enter:
  sqlcmd -E -d master
This command  logs you onto the db server using specifying master as your default db.
2) Within the SQL command prompt enter:
  alter login [MYDOMAIN\UserName] with default_database = master
This changes the default database setting against your login.
3) Then enter:
  go
This executes the command.
4) Then enter:
  quit
This quit's you out of the sqlcmd tool/prompt.
 
You screen will look something like:
C:\>sqlcmd -E -d master
1> alter login [MYDOMAIN\UserName] with default_database = master
2> go
3> quit
Posted on Monday, February 11, 2008 1:59 AM OS/Networking/Misc Apps , SQL Server | Back to top


Comments on this post: SQL Server - dropped table that was users default table - causes: Cannot Open User Default Database, Login Failed Microsoft SQL Server, Error 4064

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Tim Huffam | Powered by: GeeksWithBlogs.net