Solved

default db no more- how to recover

Posted on 2011-03-01
6
875 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now