Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I cannot connect to the database anymore, I'm getting:

Cannot open user default database. Login failed.

I have deleted the database during a previous session and then tried to recreate it. But the recreate failed.

Now I am stuck with this error, what can I do?

Edit: I'm using Windows Authentication

Any ideas?

Fixed:

use the command:

sqlcmd -E -d master

then type:

ALTER LOGIN [Your Windows Login] WITH DEFAULT_DATABASE=master

GO

:)

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Fixed it!!

use the command:

sqlcmd -E -d master

then type:

ALTER LOGIN [Your Windows Login] WITH DEFAULT_DATABASE=master

GO

share|improve this answer

You're almost certainly going to need to restore from your last backup and apply any logs.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.