Occasionally, I disconnect a database. When I try to reconnect it, I get the
message that SQL "can't find the User default database". Typically, I rein
stall the SQL Server software. There must be a better way. Is there an OSQL
command I can use? How
can I recorver from this condition without riinstalling SQL Server?
Thanks, richardYou can run the OSQL command-line utility to specify an alternate database
context and execute sp_defaultdb to change the default database for a
login. For example:
OSQL -E -d master -Q"sp_defaultdb 'MyLogin', 'MyDatabase'"
Hope this helps.
Dan Guzman
SQL Server MVP
"Richard Muschamp" <dick@.custommicro.com> wrote in message
news:23D9DDF2-EE56-4B8B-8B03-264F006F0B35@.microsoft.com...
> Occasionally, I disconnect a database. When I try to reconnect it, I get
the message that SQL "can't find the User default database". Typically, I
reinstall the SQL Server software. There must be a better way. Is there an
OSQL command I can use? How can I recorver from this condition without
riinstalling SQL Server?
> Thanks, richard|||Hi,
This problem can come due to 2 reasons
1. You have assigned the login a default database and the login do not have
a user assocoated in the default database.
a. Login to Query Analyzer
b. use <dafault databasename>
c. sp_adduser <user name>
d. Assign the required role
2. Database which is given default to the login is dropped or not available.
a. Change the login to point to a different database, Execute the below
from command prompt
b. OSQL -USa -Ppassword -d master -Q"sp_defaultdb 'Login_name', 'New
database which is default'"
Thanks
Hari
MCDBA
"Richard Muschamp" <dick@.custommicro.com> wrote in message
news:23D9DDF2-EE56-4B8B-8B03-264F006F0B35@.microsoft.com...
> Occasionally, I disconnect a database. When I try to reconnect it, I get
the message that SQL "can't find the User default database". Typically, I
reinstall the SQL Server software. There must be a better way. Is there an
OSQL command I can use? How can I recorver from this condition without
riinstalling SQL Server?
> Thanks, richard
No comments:
Post a Comment