?
Solved

default db no more- how to recover

Posted on 2011-03-01
6
Medium Priority
?
936 Views
Last Modified: 2012-05-11
is this query good to find which logins have default database that is no more
select * from master..syslogins where dbname not in (select name from sysdatabases)

how do you recover from situations like these?
0
Comment
Question by:anushahanna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 3

Expert Comment

by:mordi
ID: 35010406
Hi,
It is not clear what happened.
If you have any backup of the missing database so after restore all the users get restored also.
0
 
LVL 6

Author Comment

by:anushahanna
ID: 35010434
but that is login info, won't be in database.
0
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 668 total points
ID: 35010520
I've written a write up on how to recover from a situation where you can't login due to a missing default database.

http://www.sqlservernation.com/home/fix-for-cannot-open-user-default-database-login-failed.html
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 40

Assisted Solution

by:lcohan
lcohan earned 668 total points
ID: 35011546
Yes that should do it as the default db is stored in syslogins.dbname - from http://msdn.microsoft.com/en-us/library/ms178593.aspx

"dbname
 sysname
 Name of the default database of the user when a connection is established."
 
--slightly updated
select name,dbname from master..syslogins where dbname not in (select name from master..sysdatabases)
0
 
LVL 13

Assisted Solution

by:geek_vj
geek_vj earned 664 total points
ID: 35024541
>>is this query good to find which logins have default database that is no more
select * from master..syslogins where dbname not in (select name from sysdatabases)

Yes, the query is fine

>>how do you recover from situations like these?
In that case, you have to login using another user and change the default database of the login which is having issue.
0
 
LVL 6

Author Comment

by:anushahanna
ID: 35041735
thanks for your helpful input.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question