November 27, 2008 at 10:14 pm
Hi,
For restoring a database on a production server I am trying to delete the older db. But SQL 2005 doesnt allow the deletion of the db without it being taken offline. I suppose that the Db is being used in some way.
[p]Does moving the db to Single-User mode help in this scenario[/p].
November 27, 2008 at 10:21 pm
You can run sp_who or sp_who2 to see if anyone is in the database. Putting in single user mode will work in this case and allow you to drop the DB.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
November 27, 2008 at 10:37 pm
Thanks for fast replies. I'll run sp_who(2) before attempting deletion.
My doubt is -
Is taking the database offline and then deleting it an option at all? (rather than bringing it to the single-user mode and then deleting it.)
Thanks Once Again.
November 28, 2008 at 12:38 am
skyw (11/27/2008)
Is taking the database offline and then deleting it an option at all? (rather than bringing it to the single-user mode and then deleting it.)
Sure.
ALTER DATABASE SomeDB SET OFFLINE WITH ROLLBACK IMMEDIATE -- kicks users out of db and takes it offline
DROP DATABASE SomeDB
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 30, 2008 at 11:43 pm
🙂
Thank You.
December 2, 2008 at 1:01 am
Actually, you do not need to delete the older database in order to restore a new one from production - you can simply restore and overwrite what's already there. (RESTORE WITH REPLACE if you need to, but if the existing database is actually an older copy of the same database from production, you don't even need the "WITH REPLACE" option.)
You still need an exclusive lock on the database to do a restore though, so what you did is fine. 🙂
Vegard Hagen
Norwegian DBA, occasional blogger and generally a nice guy who believes the world is big enough for all of us.
@vegard_hagen on Twitter
Blog: Vegards corner (No actual SQL stuff here - havent found my niche yet. Maybe some day...)
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply