Solved

is there a way to a drop a DB as part of a scheduled restore?

  • 20 April 2022
  • 4 replies
  • 89 views

Userlevel 5
Badge +16

is there any way of dropping a DB prior to a scheduled restore?

 

I don’t think there is an option to do this but is there a simple way to capture the list of drops a drop them ahead of the restore starting?

icon

Best answer by Chris Hollis 17 May 2022, 01:37

View original

4 replies

Userlevel 6
Badge +15

@christopherlecky mind confirming what would be the purpose of doing so? Can’t you just restore with overwrite enabled (and drop connections) to allow it to go thru? 

Is there some failure you’re intermittently getting or just curious?

Userlevel 5
Badge +16

@Chris Hollis Unable to gain exclusive access.
this is with unconditional overwrite and drop connections enabled.

Not completely clear why but dropping the DB in the past has saved time as typically restores are done under duress.

 

in this case its a scheduled restore that is failing.

Userlevel 6
Badge +15

Apologies @christopherlecky, I didn’t see this reply.


Confirming your query was answered under a support incident. 

Issue Findings:

Support determined that there is something creating a constant logon request for that DB, meaning it is always in use regardless of the paramaters leveraged in our restore process. 

Unfortunately, there is no option built into SQL agent to drop the DB prior to restore. If this is going to be a scheduled operation then to resolve this particular issue, you can look at scripting the restore with a pre-process script. You can wrap a SQLCMD call in a .bat file.

I would be interested in finding out if you managed to try this and if this worked as you hoped?


Thanks,


Chris ​​​​​​​

Userlevel 5
Badge +16

Apologies @christopherlecky, I didn’t see this reply.


Confirming your query was answered under a support incident. 

Issue Findings:

Support determined that there is something creating a constant logon request for that DB, meaning it is always in use regardless of the paramaters leveraged in our restore process. 

Unfortunately, there is no option built into SQL agent to drop the DB prior to restore. If this is going to be a scheduled operation then to resolve this particular issue, you can look at scripting the restore with a pre-process script. You can wrap a SQLCMD call in a .bat file.

I would be interested in finding out if you managed to try this and if this worked as you hoped?


Thanks,


Chris

Hi Chris,

That is exactly the approach I took, but I have seen this issue often enough that I was just wondering if the functionality had been baked into the product. 

 

Thanks for the follow up.

Reply