Solved

default db no more- how to recover

Posted on 2011-03-01
6
907 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
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 167 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 39

Assisted Solution

by:lcohan
lcohan earned 167 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 166 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

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

839 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