Comments
1 comment
-
In the restore job, before the job step that runs the SQL Backup restore command, try adding a job step to forcibly kill all connections to the database in question. You could use something like this:USE masterDECLARE @execSql varchar(1000), @databaseName varchar(100)-- Set the database name for which to kill the connectionsSET @databaseName = '<your database name>'SET @execSql = ''SELECT @execSql = @execSql + 'kill ' + convert(char(10), spid) + ' 'FROM master.dbo.sysprocessesWHERE db_name(dbid) = @databaseNameANDDBID <> 0AND@spidEXEC (@execSql)
Add comment
Please sign in to leave a comment.
sql server 2012
I am doing a backup set restore every night to a report server. It fails about 2 times a week. The logs say the failure is because it cannot disconnect the users from the database. I run 2 restore jobs 10 minutes apart in case the first one fails. once or twice a week they both fail.