Parsing Table Differences
crancoder
Posts: 28
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
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.
Example (pseudocode):
IF(target database table A does not have field
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
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.
Redgate Software