SQL Server agent restore job fails - manual restore works

dwjongbloeddwjongbloed Posts: 30
edited March 11, 2015 8:30PM in SQL Backup Previous Versions
I have been trying to get one of my SQL Server agent jobs to restore a database and it keep failing on me. If I restore the database manual via the RedGate software on the GUI screen it works just fine. I have 2 other db's that I'm restoring via a SQL Server agent and they are working just fine. I'll post the errors below. The last error states that the DB is in use but when looking at activity monitor there is no processes open on the database. Looking for some advice as to what is going on.

*Thread 0 error: Process terminated unexpectedly. Error code: -2139684860 (An abort request is preventing anything except termination actions.)

*SQL error 3013: RESTORE DATABASE is terminating abnormally.

*SQL error 3101: Exclusive access could not be obtained because the database is in use.

Comments

  • peteypetey Posts: 2,358 New member
    Have you tried using the DISCONNECT_EXISTING option e.g.
    EXEC master..sqlbackup '-sql "RESTORE DATABASE ... WITH DISCONNECT_EXISTING..."'
    
    Peter Yeoh
    SQL Backup Consultant Developer
    Associate, Yohz Software
    Beyond compression - SQL Backup goodies under the hood, updated for version 8
Sign In or Register to comment.