January 26, 2012 at 2:55 am
I have a database on my test server,each time i want to restore on it,it always complains about exclusive access,i end up restarting the server in order to restore even after killing processes and stopping all the services connecting to it.What could be the problem with this database on this server.
“When I hear somebody sigh, ‘Life is hard,’ I am always tempted to ask, ‘Compared to what?’” - Sydney Harris
January 26, 2012 at 3:01 am
I guess this is a RESTORE WITH REPLACE, isn't it?
Just DROP the database before restoring, no need to restart the instance.
-- Gianluca Sartori
January 26, 2012 at 3:18 am
Yes it's with replace but drop fails it says database is in use.If dropped fine,can I continue dropping a database each time I want to restore I can restore other databases without this problem.
“When I hear somebody sigh, ‘Life is hard,’ I am always tempted to ask, ‘Compared to what?’” - Sydney Harris
January 26, 2012 at 3:25 am
You have to identify the sessions using the database and kill them.
The easiest way is querying sys.sysprocesses (I know, it's a compatibility view, but does the trick very fast).
SELECT spid
FROM sys.sysprocesses
WHERE DB_NAME(dbid) = 'NameOfDatabaseToDrop'
-- Gianluca Sartori
January 26, 2012 at 3:30 am
OK,I CAN LIST ALL THE PROCESSES AND KILL THEM EXCEPT ONE WHICH SAYS CAN NOT KILL OWN PROCESS.
“When I hear somebody sigh, ‘Life is hard,’ I am always tempted to ask, ‘Compared to what?’” - Sydney Harris
January 26, 2012 at 3:34 am
Then, it's the session that runs the KILL statement, your current session in SSMS.
Issue a "USE master" command and you should be fine.
-- Gianluca Sartori
January 26, 2012 at 3:34 am
That's your own connection. You're blocking the restore with your own session, make sure you're connected to a database other than the one you are restoring over.
p.s. Please don't type in all caps, it's the equivalent of shouting at us.
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
January 26, 2012 at 3:52 am
Thank you.Sorry for the caps.
“When I hear somebody sigh, ‘Life is hard,’ I am always tempted to ask, ‘Compared to what?’” - Sydney Harris
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply