Tim Huffam

Dotting the I and crossing the T of I.T.

  Home  |   Contact  |   Syndication    |   Login
  129 Posts | 0 Stories | 874 Comments | 677 Trackbacks

News

Archives

Post Categories

Interesting Blogs/Links

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