开发者

Can't log in to SQL Server 2008 Management Studio

I think something happened to an mdf file on disk.

When I try to start SQL Server 开发者_如何学CMgmt Studio (SQL Server 2008, Win 7 x64), I get an error:

"Cannot open user default database."

Since I can't connect at all, how do I fix this?

I have tried connecting to other dbs using osql, but always get an error.

Thanks for any workarounds...


The easiest way to do this is via command line. You keep opening connections using SSMS that fail...

Using command line you'll have one connection and delimit the login name correctly: "[SVR\USR]"

sqlcmd -S InstanceName -d master -E -Q"ALTER LOGIN [SVR\USR] WITH DEFAULT_DATABASE = master"

or replace -E with -U SQLLogin -P Password if you have a SQL login handy


When connecting from Management studio, In the "connect to server" dialog box, before connecting, click "Options" and change the "Connect to database" dialog box to "master".


Login as an administrator and change your default database: ALTER LOGIN ... WITH DEFAULT_DATABASE = .... If you're not an administrator, ask an administrator to do it. If you must log in in the database in question, ask an administrator to investigate whi the database is offline.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜