Clear destination database before sync

Compares and synchronizes SQL Server databases, backups and scripts.

Moderators: JonathanWatts, Chris Auckland, David Atkinson, eddie davis, Anu Deshpande, Michelle Taylor, alice.easey, james.billings, chengvoon.tong

Clear destination database before sync

Postby brian.chiu.rt » Mon May 07, 2012 8:24 pm

does anyone know if there's a way to clear the destination database before each sync?

I know this process might be a bit weird but what we're trying to do here is to create a schema backup for multiple databases by using redgate to sync with a staging DB before creating a backup of it.

thanks,
brian
brian.chiu.rt
 
Posts: 2
Joined: Mon May 07, 2012 8:19 pm

Postby james.billings » Thu May 10, 2012 12:20 am

A standard sync will theoretically have the same effect (making the target DB match the source). This is the same as clearing down everything from the target then syncing. So I think I'm perhaps missing the point of what you're trying to do.

There's no option in SQL Compare to do this; but a workaround would be to have an empty database on your server, and first sync from this to the target (which should drop everything) then run your usual sync afterwards. But as I said above, the end result would be the same as the sync you're already doing.
james.billings
 
Posts: 1144
Joined: Wed Jun 16, 2010 11:10 am
Location: My desk.

Postby David Atkinson » Thu May 10, 2012 8:54 am

Are you running this as part of an automated process? If so, an alternative is to run the following:

sqlcmd -SYourServer -Q "ALTER DATABASE YourDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE YourDB"

sqlcmd -SYourServer -Q "CREATE DATABASE YourDB"

Can I ask why you're creating these schema backups? How will they be used?

David Atkinson
Product Manager
Red Gate
David Atkinson
 
Posts: 1124
Joined: Mon Dec 05, 2005 4:54 pm
Location: Twitter: @dtabase


Return to SQL Compare 10

Who is online

Users browsing this forum: No registered users and 1 guest