Friday, February 26, 2010

Cannot open user default database. Login failed. Login failed for user ‘UserName’. (Microsoft SQL Server, Error: 4064)

Obliviously, I deleted the database which I had set as the default database to my login in SQL Server 2008. To change it, I double-clicked on my login under Security -> Logins but it threw me an error stating unable to login to default database. After a headache of 20 minutes, I found the solution:
1. In the Connect to Server window, click on the Options button.

2. Under the Connection Properties tab, type the name of the existing database or the default database (usually 'master') at 'Connect to database:' option. (Drop-down will again try to connect so its no use of trying).

3. Then click Connect. Voila!



Thought this might be helpful than to try other sqlcmd options from the command prompt.

No comments:

Post a Comment