Column rename - can I override this?

MartinHMartinH Posts: 82 Bronze 2
edited April 29, 2005 1:07PM in SQL Compare Previous Versions
Hi:

I have a database I'm updating that has an old column name of 'Banco_id' and this field is no longer needed, but a new column 'Banco' will be introduced, both fileds are integers.

When I run SQLCompare it trys to rename the column, but the new field as ForeignKey constraints and the update fails when the ForeignKey is being added.

Is there a way I can indicate I *don't* want column renames, but a drop followed by an add?

TIA,
MartinH.

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi Martin,

    Thanks for asking. Some of the more recent versions of SQL Compare have a little safety-net built in that will try to save data by assuming that you've renamed a column. In your case, the logic would assume that this column is a rename and copy the data over from Banco_id to Banco in the new database. Normally this would not cause a problem, because any new column that you append to a table will have values 'filled in' by the SQL Server anyway, either NULLS or the default column value.

    There isn't a way of turning off the data copying that SQL Compare is doing, so it's worthwhile to concentrate on the reasons that the Foreign Key constraint fails. I'm guessing that the new constraint is checking existing data on creation, so maybe recomparing with the 'ignore with nocheck' option turned on may help.

    Please let me know if this gets the script working.
  • MartinHMartinH Posts: 82 Bronze 2
    Please let me know if this gets the script working.

    Brian:

    This really isn't a problem, more an inconvenience. As the column os obsolete I just deleted it before doing the compare.

    I just thought it might be a good idea to have an option for this.

    Regards,
    Martin.
This discussion has been closed.