Using SQL Compare filters with DLM Automation cmdlets
Published 10 March 2016
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 three DLM Automation cmdlets that use SQL Compare filters:
By default, this cmdlet will use the Filter.scpf file included in the source schema when generating the update script.
By default, this cmdlet will use the Filter.scpf file included in the source schema when updating the target schema.
This cmdlet will use a filter specified via FilterPath when cleaning out / creating a temporary database to validate the script folder schema.
The source schema must be either a scripts folder or a NuGet database package.
For any of these cmdlets, 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.
$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).