Options

Parsing Table Differences

crancodercrancoder Posts: 28
edited January 10, 2008 11:52AM in SQL Compare Previous Versions
I'm trying to build a script which puts conditionals around ALTER TABLE statements.

Example (pseudocode):

IF(target database table A does not have field B)
BEGIN
ALTER TABLE A add field B....
END

I'd rather not do this by parsing the script output which SQL Compare creates. Is there a class that provides an enumeration of the fields that would need to be added or changed in the target database? It is not feasible to iterate through all of the columns, unchanged or not, in the table.

Thank you.

Comments

  • Options
    I'm afraid there isn't any such class available.

    SQL Compare goes straight from the Differences object (which contains all of the fields in a table, without individually noting whether they're changed or not, so you would have to iterate through all the fields) to the Work object (which basically just contains the script output, and is possibly less useful for parsing than the script output itself - it doesn't contain any way of picking out changes to fields from any other batch of T-SQL short of parsing the script in each batch).

    The Messages object, which is a member of the Work object, contains a list of changes, but only on the per-table level, not at the per-field level.
    Software Developer
    Redgate Software
Sign In or Register to comment.