DLM Automation

Using SQL Compare filters with DLM Automation cmdlets

A scripts folder can include a Filter.scpf file that contains SQL Compare filters. These filters exclude certain database objects when comparing schemas.

There are two DLM Automation cmdlets that use SQL Compare filters:

  • New-DlmDatabaseRelease
    By default, this cmdlet will use the Filter.scpf file included in the source schema when generating the update script.
  • Sync-DlmDatabaseSchema
    By default, this cmdlet will use the Filter.scpf file included in the source schema when updating the target schema.

The source schema must be either a scripts folder or a NuGet database package.

For either cmdlet, you can use the -FilterPath parameter to specify an alternative filter file if you want to override the filter file generated by SQL Source Control in the source schema. You can also use this parameter to specify a filter file when none is included in the source schema.

Example:

$scriptsFolder = "C:\Work\Scriptsfolder\"
$test = New-DlmDatabaseConnection -ServerInstance "test01\sql2012" -Database "Test" -Username "sa" -Password "P@ssw0rd" 
$filter = "C:\Work\MyFilter.scpf" 
New-DlmDatabaseRelease -Target $test-Source $scriptsFolder -FilterPath $filter

This example demonstrates using the MyFilter.scpf filter file to determine which database objects are included and excluded when the New-DlmDatabaseRelease cmdlet generates the update script. This will override any filter file present in the scripts folder.

Creating a filter file

A filter file can either be created using SQL Compare.

To create a new filter file, see Using filters (SQL Compare documentation).


Didn't find what you were looking for?