Thursday, October 11, 2007

Bug: RESTORE cannot process database 'database_name' because it is in use by this session.

Error:

TITLE: Microsoft SQL Server Management Studio
------------------------------

Restore failed for Server 'database_name'. (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Restore+Server&LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

System.Data.SqlClient.SqlError: RESTORE cannot process database 'database_name' because it is in use by this session. It is recommended that the master database be used when performing this operation. (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.3042.00&LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------



SOLUTION:
You can't restore a DB through the SSMS interface if it's your default DB for your login! Change the login's default DB then restore.

More detailed description:
Well, there's the obvious problem that you can't restore a database you have an open connection to, but in this case the cause was less obvious. I canceled out of the restore database dialog in SSMS and check the activity monitor. There were a few open connections for the database, so I closed my connections and killed any idle connections from other users. I tried it again. Same error message.
It turns out the problem is that the database I have setup as my windows logon default DB is the same DB I was trying to restore. So when SSMS makes the connection in the background, it creates a connection to that database. I had to change the default DB in my security info, and then restore the database.
Definitely a perfect candidate for the theme of this blog: posting errors and solutions for stuff I couldn't find posted elsewhere on the net. This one's probably out there, but it's not easy to find via a search engine, so hopefully this helped.

44 comments:

Anonymous said...

Definitely helped. I was pulling my hair out!!!! Thanks

Anonymous said...

this helped me, thanks for taking the time to post!

Anonymous said...

Thanks! This just saved my bacon :-)

Anonymous said...

helped mann.. thanks.

Anonymous said...

As the previous posters said, "Thanks!!". Saved me hours of figuring out what was wrong.

Anonymous said...

I knew i loved the internet for a reason. Thank you.

Anonymous said...

You saved me a lot of time and pain... I should've read your post before spending couple of hours on this stupid thing. Sometimes life get miserable with microsoft products...

Anonymous said...

Hey. I don't normally leave comments, but I just wanted to say thanks for the great information. I have a blog too, though
I don't write as good as you do, but if you want to check it out here it is. Thanks again and have a great day!

Feral Druid Leveling Build

Anonymous said...

Thank you so much! I was going nuts!

Anonymous said...

Thanks a million ! It saved a ton of my time

Anonymous said...

unbelievable! 1st this has happened to me using this version of SQL Server, never happened in previous versions!

Anonymous said...

You don't have to change the Default DB actually. You cna simply close all queries and disconnect all connections. Then connect, and use the options dialog to select browser server for more... and select anything but the target DB. Easier than changing your settings for default and having to change back ! Chrs. MemeDeveloper

Anonymous said...

Now I am ready to do my breakfast, when having
my breakfast coming again to read more news.
Also see my website: teen porn post

Anonymous said...

Howdy! Do you know if they make any plugins to protect against hackers?

I'm kinda paranoid about losing everything I've worked hard on.
Any suggestions?
My blog post ... Young teen daughter abuse

Anonymous said...

Hi everyone, it's my first go to see at this site, and article is in fact fruitful for me, keep up posting such articles or reviews.
My site > passed out porn

Anonymous said...

This piece of writing is genuinely a pleasant one it helps new web visitors, who
are wishing in favor of blogging.
Here is my web-site ; Apple Valley

Anonymous said...

Fantastic website you have here but I was curious about if you knew of any message boards that cover
the same topics talked about here? I'd really love to be a part of group where I can get advice from other experienced individuals that share the same interest. If you have any recommendations, please let me know. Cheers!
Also see my page: Blackberry Anitvirus

Anonymous said...

Hello, just wanted to tell you, I enjoyed this blog post.
It was helpful. Keep on posting!
Feel free to visit my weblog ; discount

Anonymous said...

Your style is unique in comparison to other folks I've read stuff from. Many thanks for posting when you've got the opportunity, Guess I'll just bookmark this blog.
My website :: friv games

Anonymous said...

Malaysia & Singapore & brunei ideal on the internet blogshop
for wholesale & supply korean add-ons, accessories, earstuds, necklace, rings, hair,
trinket & bracelet accessories. Offer 35 % wholesale rebate. Ship Worldwide
Here is my page :: unemployment.ohio.gov

Anonymous said...

Malaysia & Singapore & brunei greatest online blogshop for wholesale &
supply korean add-ons, earrings, earstuds, necklace, rings, hair, bracelet
& bangle accessories. Deal 35 % wholesale price cut. Ship Worldwide
Feel free to visit my blog :: Bed bugs symptoms

Anonymous said...

You have made some really good points there. I checked on the internet to learn more about the issue and found most people will go along with your
views on this web site.
Check out my website : Luis Souto ecommerce projects handled accesorios nauticos

Anonymous said...


You made some good points there. I looked on the net for additional information about the issue and found most people will go along with your views on this website.

Anonymous said...

I wanted to thank you for this good read!! I certainly loved every little bit of
it. I have you book-marked to check out new things you
post…
Feel free to visit my page Photography Tricks

Anonymous said...

What's Going down i am new to this, I stumbled upon this I have discovered It positively helpful and it has helped me out loads. I am hoping to contribute & help different customers like its aided me. Good job.
Also visit my weblog :: Family vacation at Upper James Manor

Anonymous said...

Hi! I've been following your site for a while now and finally got the courage to go ahead and give you a shout out from New Caney Tx! Just wanted to mention keep up the great work!
Here is my site ; seo services india

Anonymous said...

Do you mind if I quote a few of your articles as long as I provide credit and sources back to your website?

My blog site is in the very same niche as yours and my users would truly benefit from a lot of the information you provide here.
Please let me know if this alright with you. Many thanks!
my web page :: Cheap YouTube Views

Anonymous said...

I've learn a few excellent stuff here. Certainly worth bookmarking for revisiting. I wonder how a lot attempt you put to make this sort of excellent informative site.

Here is my blog post Mens Health Manchester

Anonymous said...

Howdy! I could have sworn I've visited this blog before but after looking at some of the articles I realized it's new to me.

Regardless, I'm certainly delighted I discovered it and I'll be bookmarking it and
checking back frequently!

my site - Consultant Appointments Manchester

Anonymous said...

Currently it аppears like BlogΕngine is thе toρ blogging platfоrm out there гіght now.
(from what I've read) Is that what you are using on your blog?

Feel free to surf to my page :: raspberry ketone

Anonymous said...

Hello! I know this is kinda off topic nevertheless I'd figured I'd ask.
Would you be interested in trading links or maybe guest writing
a blog article or vice-versa? My site discusses a lot
of the same subjects as yours and I think we could greatly benefit from each
other. If you might be interested feel free to shoot me an
email. I look forward to hearing from you! Great blog by the way!


my site; Arabic Books

Anonymous said...

This is the perfect webpage for anybody who wants to find out
about this topic. You understand a whole lot its almost tough
to argue with you (not that I personally will need to…HaHa).

You definitely put a brand new spin on a subject that's been discussed for many years. Wonderful stuff, just wonderful! ageless male - ageless male - http://enfant-dysphasie.fr/doku.php/testosterone_tablets_to_boost_libido_and_testosterone_in_males

Review my web page :: new vitality ageless male reviews

Anonymous said...

It's impressive that you are getting thoughts from this article as well as from our discussion made at this place.

my web blog: Shyla Gets Fucked

Anonymous said...

It's a shame you don't have a donate button! I'd definitely donate to this outstanding blog! I guess for now i'll settle for book-marking and adding your
RSS feed to my Google account. I look forward to fresh updates and will share this website with my Facebook group.

Talk soon!

Also visit my blog webcam sex videos

Anonymous said...

I have been browsing online more than 4 hours today,
yet I never found any interesting article like yours.

It's pretty worth enough for me. Personally, if all website owners and bloggers made good content as you did, the internet will be much more useful than ever before.

my site http://www.wildpartygirls.org/

Anonymous said...

Hey there! I just want to offer you a huge thumbs up for your excellent info you've got here on this post. I'll be returning to your
blog for more soon.

Also visit my website; porno tube free

Anonymous said...

I was recommended this web site through my cousin. I'm no longer sure whether or not this publish is written via him as nobody else know such unique approximately my trouble. You are incredible! Thank you!

Also visit my webpage ... http://www.babesflick.com/

Anonymous said...

Hello there! I know this is kinda off topic but I was wondering which blog platform are you using for this site?
I'm getting tired of Wordpress because I've had problems with hackers
and I'm looking at alternatives for another platform. I would be fantastic if you could point me in the direction of a good platform.

My weblog - dabagirls.com

Anonymous said...

I love what you guys tend to be up too. This sort of clever work and coverage!
Keep up the good works guys I've added you guys to our blogroll.

Look at my blog :: http://www.cuteteenporn.net/video/29592/spicy-youngster-3-some.html

Anonymous said...

Hello! I've been following your web site for a while now and finally got the bravery to go ahead and give you a shout out from Huffman Tx! Just wanted to say keep up the good work!

my blog post ... pictures free of sex

Anonymous said...

Touche. Outstanding arguments. Keep up the amazing spirit.


Look at my web page - book of ra free android

Anonymous said...

Good day I am so thrilled I found your website, I really found you by error,
while I was researching on Bing for something else, Anyhow
I am here now and would just like to say cheers
for a fantastic post and a all round interesting blog (I also love the theme/design), I don't have time to read through it all at the minute but I have bookmarked it and also added your RSS feeds, so when I have time I will be back to read more, Please do keep up the superb work.

Take a look at my weblog Young Asian Girls

Unknown said...

lol I wrote my blog post: http://dotnetxperience.blogspot.com/2013/10/sql-server-2008-r2-restore-cannot.html
to see your already exists :)

thanks to all knowledge sharers

Anonymous said...

smokeless cigarettes, e cigarette, electronic cigarettes, vapor cigarette, electronic cigarettes, e cig forum