Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
delpiero
Yak Posting Veteran
98 Posts |
Posted - 2005-05-16 : 23:39:40
|
| Hi all, Suppose my Windows-authenticated "MyMachine\administrator" SQL Server login has user database "Purchase" as the default database. When I open Enterprise Manager or Query Analyzer while connected as MyMachine\administrator in Windows, the login is OK. But suppose I detach the database "Purchase", and somehow reboot the machine and then open Enterprise Manager/Query Analyzer again under the same Windows a/c, the connection fails because it can't find the default database "Purchase" which was detached. I was forced to connect using the "sa" a/c. Is there any method to select a database other than "Purchase" to connect in this case, without having to use the "sa" a/c?Thanks,delpiero |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2005-05-16 : 23:52:53
|
| You need to change the default database for the other login, and make sure it's a user in other databases. You can change the default database using:EXEC sp_defaultdb @loginame = 'login, @defdb = 'defaultdatabase'MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
delpiero
Yak Posting Veteran
98 Posts |
Posted - 2005-05-17 : 22:47:01
|
| Thanks, but suppose the original default database for that login has been detached, and it prompts me error about connecting to default database.To change the default database of the login, besides logging in as another account to run the sp_defaultdb, is there anything else I can do? I may not have any other account besides my original account I was trying to login to that default database.Thanks,delpiero |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2005-05-17 : 22:56:06
|
| That would suck. You could use osql to do it. Have you thought about that?MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
delpiero
Yak Posting Veteran
98 Posts |
Posted - 2005-05-18 : 00:19:47
|
| But suppose I only have one account which has its default database detached. That account is a Windows account. So I login as that windows account and type:osql -Eit would still show default database not found and prevent me from logging in.But I can't use /P as I dun have any other a/c . |
 |
|
|
|
|
|
|
|