Kashif
Kashif

Reputation: 14430

Change default db to Master db in SQL Server

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.

Upvotes: 1

Views: 4655

Answers (2)

Joe Stefanelli
Joe Stefanelli

Reputation: 135808

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'

Upvotes: 2

Mitch Wheat
Mitch Wheat

Reputation: 300559

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

Upvotes: 1

Related Questions