On my SQL server 2008, i have a SQL agent job to restore a database on nightly basis. Procedure:
- find latest backup on other server
- Kill all conenction to the destination database
- Restore destination database with replace, recovery
It failed last weekend because the database was being used by a system process (spid 11 checkpoint). since I couldnt kill the system process, I fixed this by restarting sql server.
It failed this weekend as well with same error (checkpint process in this database as from sp_who
) and when I run:
SELECT session_id,request_id,command,status,start_time
FROM sys.dm_exec_requests
WHERE session_id = 11
It shows:
11 0 CHECKPOINT background 2010-04-06 10:17:49.103
I cant restart the server every time it fails.
Can anyone please help me in fixing this?
Thanks in advance
Manjot
Don't kill SPIDs less than 50! These are system processes
To see if you can take the DB out of the "restoring" state try
Edit, after comment
Assuming you want to restore the DB and don't care about keeping it...
Stop SQL Server, move the MDF/LDF somewhere else, start SQL Server.
The DB comes up offline (I forget the exact status). Then you can drop it, restore it
Rather than killing the open connections, try
Then do the restore, or better yet, drop it, then restore.
After you're done, don't forget to return the database to its previous state:
fixed- since it was restored daily. i have excluded it from re-index, dbcc checkdb, update stats etc maintenance plans.
even though they ran during seperate schedule, excluding the database fixed the issue.