Change default db to Master db in SQL Server
I have deleted my default db now I can not login using sql server authentication. Ho开发者_运维技巧w 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.
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>
.
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'
In SSMS: Server->Security->General Tab->Default Database
精彩评论