SQL Change Automation 4

Comparison and script generation options

SQL Change Automation provides an effective way to generate new migration scripts within your project. The tool uses Redgate's SQL Compare, and SQL Data Compare engines. SQL Change Automation uses most of the factory default comparison and script generation options that ship with SQL Compare itself.

If fine-grained control is required over the script-generation behavior, then the standard SQL Compare settings can be customized at the project level.

Customizing database comparison and script generation options

In order to set the wanted script comparison and generation options, some editing of your SQL Change Automation project's .sqlproj file is required.

Choose from one or more of the available database comparison and script generation options. These are listed below along with the default value that SQL Change Automation uses:

Schema comparison options

  <!-- "Deploy all dependencies" SQL Compare option -->

  <!-- "Add object existence checks" SQL Compare option -->

  <!-- "Use DROP and CREATE instead of ALTER" SQL Compare option -->

  <!-- "Disable DDL triggers during deployment" SQL Compare option -->

  <!-- "Ignore extended properties" SQL Compare option -->

  <!-- "Ignore comments" SQL Compare option -->

  <!-- "Ignore SET QUOTED_IDENTIFIER and SET ANSI_NULLS statements" SQL Compare option -->

  <!-- "Ignore collations" SQL Compare option -->

  <!-- "Force column order" SQL Compare option (set to False to force column order) -->

  <!-- "Ignore database and server name in synonyms" SQL Compare option -->

  <!-- "Ignore tSQLt framework and tests" SQL Compare option -->

  <!-- "Ignore DML triggers" SQL Compare option -->

  <!-- "Ignore INSTEAD OF triggers" SQL Compare option -->

  <!-- "Ignore filegroups, partition schemes and partition functions" SQL Compare option -->

  <!-- "Ignore NOT FOR REPLICATION" SQL Compare option -->

  <!-- "Ignore fill factor and index padding" SQL Compare option -->

  <!-- "Ignore LOCK properties of indexes" SQL Compare option -->

  <!-- "Ignore statistics" SQL Compare option -->

  <!-- "Ignore data compression" SQL Compare option -->

  <!-- "Ignore full-text indexing" SQL Compare option -->

  <!-- "Ignore replication triggers" SQL Compare option -->

  <!-- "Ignore indexes" SQL Compare option -->

  <!-- "Ignore permissions" SQL Compare option -->

  <!-- "Ignore white space" SQL Compare option -->

  <!-- "Ignore WITH NOCHECK" SQL Compare option -->

  <!-- "Ignore identity seed and increment values" SQL Compare option -->

  <!-- "Use case-sensitive object definition" SQL Compare option -->
  <!-- "Ignore bindings" SQL Compare option -->

  <!-- "Ignore event notification on queues" SQL Compare option -->

  <!-- "Ignore brackets in object names" SQL Compare option -->

  <!-- "Ignore WITH element order" SQL Compare option -->

  <!-- "Ignore WITH ENCRYPTION" SQL Compare option -->
  <!-- "Ignore authorization on schema objects" SQL Compare option -->

  <!-- "Ignore STATISTICS_NORECOMPUTE property on indexes" SQL Compare option -->

  <!-- "Consider next filegroups in partition schemes" SQL Compare option -->
  <!-- "Ignore NOCHECK and WITH NOCHECK" SQL Compare option -->

  <!-- "Ignore user properties" SQL Compare option -->

  <!-- "Ignore user's permissions and role memberships" SQL Compare option -->

  <!-- "Add WITH ENCRYPTION" SQL Compare option -->

  <!-- "Decrypt encrypted objects" SQL Compare option -->

  <!-- "Use database compatibility level" SQL Compare option -->

  <!-- "Ignore dynamic data masking" SQL Compare option -->

  <!-- "Auto map similar columns" SQL Compare option -->

  <!-- "Add ONLINE = ON when creating indexes" SQL Compare option -->

Data comparison options

  <!-- "Drop primary keys, indexes, and unique constraints" SQL Data Compare option -->

  <!-- "Disable foreign keys" SQL Data Compare option -->

  <!-- "Include timestamp columns" SQL Data Compare option -->

  <!-- "Use case-sensitive object definition" SQL Data Compare option -->

  <!-- "Force binary collation (case-sensitive)" SQL Data Compare option -->

  <!-- "Trim trailing white space" SQL Data Compare option -->

  <!-- "Disable DML triggers" SQL Data Compare option -->

  <!-- "Disable DDL triggers" SQL Data Compare option -->

  <!-- "Don't include comments in the deployment script" SQL Data Compare option -->

  <!-- "Reseed identity columns" SQL Data Compare option -->

  <!-- "Skip integrity checks for foreign key constraints" SQL Data Compare option -->

  <!-- "Transport CLR data types as binary" SQL Data Compare option -->

  <!-- "Compress temporary files" SQL Data Compare option -->

  <!-- "Treat empty string as NULL" SQL Data Compare option -->

  <!-- "Use checksum comparison" SQL Data Compare option -->

  <!-- "Use maximum precision for floats" SQL Data Compare option -->


To override a given option, copy the option to the top of the project file within a <ProjectGroup> element. For example, to have SQL Change Automation ignore DML trigger objects when importing from your connected database, add the following under the <Project> element of your project file:

Example option snippet


CREATE OR ALTER for re-runnable scripts

In addition to the options supported by SQL Compare, SQL Change Automation also provides the UseCreateOrAlterForRerunnableScripts option. This defaults to False.  If set to True, Programmable objects will be scripted using CREATE OR ALTER syntax instead of DROP and CREATE.
Changing this setting will not automatically update programmable objects which have already been scripted to the project. It is possible to regenerate these by deleting the existing scripts and rerunning the generate migrations step. Note that doing this will cause the programmable objects to be redeployed as their checksums will have changed.

Combining script generation settings with a SQL Compare filter

At times it may be useful to supplement changes to your script generation settings with a filter.

For example, if you wish to set the SyncOptionIgnoreUsersPermissionsAndRoleMemberships to True so that SQL Change Automation does not script out permissions for users, you may also want to add a filter to prevent the users from being scripted as well. See Filtering for more information and an example filter for this purpose.

Unsupported options

Options that are "locked" to ensure deployment reliability

A number of SQL Compare options would, if switched on, cause scripts to be generated that might not work within all of your target environments. In order to ensure that a given migration can be successfully executed against all of your databases, there are a number of options that are locked to the Off setting:

  • Ignore constraint names
  • Ignore system-named constraint names
  • Ignore DML trigger order
  • Ignore certificates, symmetric keys and asymmetric keys
  • Ignore check constraints
  • Ignore foreign keys
  • Ignore identity properties
  • Ignore nullability of columns
  • (Data Compare) Ignore underscores in object names
  • (Data Compare) Ignore spaces in object names
  • (Data Compare) Include indexed views
  • (Data Compare) Exclude identity columns

Other locked options

Additionally, a number of script generation options are locked, as follows:

  • Don't use transactions in deployment scripts = On. SQL Change Automation automatically includes transaction handling to your deployment. To prevent transactions from being used, see Transaction Handling in SQL Change Automation.
  • Don't add error handling statements to deployment scripts = On. SQL Change Automation uses the error-handling conventions of SQLCMD, which do not require the per-statement error handling of SQL Compare.
  • Add Database Use Statement = Off. SQL Change Automation automatically sets the database context prior to executing your migration script, so it is not necessary to include the USE statement in your scripts.
  • Do Not Output Comment Header = On. SQL Change Automation produces its own comment header in the .sql files that are output during the build process.
  • Ignore migration scripts for databases = On. This option relates to the SQL Source Control product and therefore is not relevant to SQL Change Automation script generation.
  • Database Project compatible script folder output = Off. This option relates to SQL Server Data Tools (SSDT) database projects and therefore is not relevant to SQL Change Automation script generation.
  • Don't use ALTER ASSEMBLY to change CLR objects = Off. If you would like to apply greater control to how your SQLCLR objects are deployed, we recommend using the method described in Deploying Assemblies.

Didn't find what you were looking for?