Capture warnings

bhopenwbhopenw Posts: 39
edited June 3, 2009 1:59PM in SQL Compare Previous Versions
From the cmd line can you capture or get warnings that a table and/or column will be dropped before a sync is committed?

If not is there any way to get this before a sync job?

I have automation setup to auto sync databases, and I have new requirement to not sync a DB if a table and/or column will be drop. Basically, they don't want to auto sync a database if data loss is going to occur w/o a backup.

Any and all help would be great

BJHop

Comments

  • Okay

    I was able to capture a table drop by examining the results of a sync script creation (Up script) command. I am running in Powershell therefore I was able to look of a line that begin with 'TABLE' and contains '<<'

    Now I just need a way to find column drops which I think will be a bit more of a challenge.

    Again any and all ideas are welcome

    thanks,

    BJHop
  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Hi,

    I had done something similar for DOS quite awhile back by running SQL Compare, examining the output, and using it to build a command that excludes all tables containing the double-arrows to prevent any table drops. Here is the forum post containing the batch file:
    http://www.red-gate.com/MessageBoard/vi ... sqlcompare
  • While I have got the table drop capture working I am searching for a way to see a column drop. I believe that only way to get this done is to use the SDK.

    I that is the way I'm going to move now, unless, anyone has a way w/o the SDK.

    Thanks,

    BJHop
  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Whether you use the SDK or the command-line, I think that the bottom-line is the same: you can synchronize at the table-level, but not omit changes to individual columns from the script.

    Using the SDK, the best idea I've had would be to analyze all tables that have a status of "different" and create a migration script just for that table using Regions, and loop through the Regions looking for the DROP COLUMN command and find a way to rip that SQL out of the migration.
  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Hi,

    I've had another look at this issue, and Regions are not the right way to go -- they are only useful when scripting an individual object from one database. I have put together a working example of how you can eliminate column drops from the migration script. This may be of interest to you:
    http://labs.red-gate.com/index.php/Filt ... ion_script
  • Brian

    Good stuff, I like what you have done. This does look to be the way to go, thanks. Nevertheless, I think I am going to be push back on the BA to see if I can change the requirement to force backup for Table drops only for this release. This way I don't have to add the complexity of the SDK to my scripts for to a release due next week.

    Again thank you

    BJHop
Sign In or Register to comment.