Thursday, March 22, 2012

Cannot open user default database - login failed

Hey,

I renamed a database, and it happened to be my default; so I basically screwed myself, because I can't change it through script (doesn't exist or you don't have permissions). What can I do?

Thanks.

Well do you have another database?

If you do then on the connect screen click the "options" button and pick the other database in the drop down list. Then you can log in and change your default.

|||

Hey,

I do, but still no result; because of the default database problem, as I go to connect, it gives me that error... I don't have the option to even try that unfortunately. Any other ideas?

Thanks.

|||

Well what database are you using? Sql Server 2005, 2000?

Anyway, I had the same problem as you, but I changed my default database from outside SqlServer using the DOS Command prompt.

The method to do this is here. It's pretty simple and easy.


http://support.microsoft.com/?kbid=307864

|||

If you're using SQL2005, open Management Studio->new a query (connect to Database Engine)->modify Options, change 'Connect to database' DropdownList to a valid database name (choose one your account can access)->Connect-> Execute the following system procedure:

sp_defaultdb 'youlogin','newdefaultdatabasename'

If you're using SQL2000 Query Analyzer, enter something like 'SQLInstanceName;database=dbname' in the 'SQL Server' textbox and connect, then execute the system procedure as above.

No comments:

Post a Comment