all groups > sql server programming > june 2005 >
You're in the

sql server programming

group:

Help, Mr. Wizard!


Help, Mr. Wizard! Paul Pedersen
6/13/2005 10:49:02 PM
sql server programming: I did a bad, bad thing.

I set my default database to some database, then I detached it. Now I can no
longer log in to SQL Server to reattach it.

What do I do now?





Re: Help, Mr. Wizard! Paul Pedersen
6/13/2005 10:53:23 PM
PS. Error message is:

A connection could not be established to (local).

Reason: Cannot open user default database. Login failed..




[quoted text, click to view]

Re: Help, Mr. Wizard! Paul Pedersen
6/14/2005 12:41:51 AM
Woo hoo, it worked! Thanks.

I was already playing around with osql but couldn't get it to log in either.
It turns out that I have to refer to the server as (local) with parentheses
rather than local without parentheses.




[quoted text, click to view]

Re: Help, Mr. Wizard! Paul Pedersen
6/14/2005 12:42:02 AM
Thank you.

"Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in
message news:O04jutKcFHA.3840@tk2msftngp13.phx.gbl...
[quoted text, click to view]

Re: Help, Mr. Wizard! David Portas
6/14/2005 7:37:49 AM
If you don't have another account account to login with you should still be
able to use OSQL to change your own default database.

Type the following at the command prompt:

For Windows authentication:
osql -E -S server -d master -Q "EXEC sp_defaultdb 'login' ,
'new_default_database'"

For SQL authentication:
osql -U login -P password -S server -d master -Q "EXEC sp_defaultdb 'login'
, 'new_default_database'"

The above untested so check out the syntax in Books Online.

--
David Portas
SQL Server MVP
--

Re: Help, Mr. Wizard! Tibor Karaszi
6/14/2005 8:36:46 AM
Login using some other account and change the default database for your account.

Or, if above is not possible, use ISQL.EXE and login with the problematic account and change default
database using sp_defaultdb.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/


[quoted text, click to view]

AddThis Social Bookmark Button