views:

32

answers:

2

I have deleted my default db now I can not login using sql server authentication. How can I change default db back to Master db

EDIT: I cannot login using sql server authentication. It gives me error

Cannot open user default database. Login failed. Login failed for user 'xyz'. (Microsoft SQL Server, Error: 4064)

Thanks.

+1  A: 

In SSMS: Server->Security->General Tab->Default Database

Mitch Wheat
Thanks Mitch, I know this option but I can not login and I don't have access to the server from where I can login using Windows Authentication. Please see my edit.
Muhammad Kashif Nadeem
If you can't login, you need to talk to an admin that can login...
Mitch Wheat
+1  A: 

Connect via SSMS. In the connection dialog box, click on the "Options >>" button and change the "Connect to database:" option to be Master instead of <default>. alt text

This should get you in. Then you can use the command below to change your login's default DB.

Exec sp_defaultdb @loginame='login', @defdb='master'
Joe Stefanelli