SQL Release

Using SQL Compare filters in SQL Release

When generating an update script and in pre- and post- deployment checks, SQL Release will apply filters you've specified in SQL Source Control.

The -Source schema (such as a scripts folder or NuGet package) may include a Filter.scpf file that contains filters to exclude or include certain objects in the database. These are the same set of filters you've specified in SQL Source Control. 

These are "SQL Compare filters" as they are part of the SQL Compare engine which both SQL Source Control and SQL Release use to run schema comparisons.

Using a different filter file

If these filters don't exclude objects that you may want to exclude when deploying to a target database, you can provide alternative filters for SQL Release to use. For example, your database may include some extra tables used for testing, which you want to exclude when deploying to production.


$staging = New-DlmDatabaseConnection -ServerInstance 'staging01\sql2012' -Database 'Staging' -Username 'sa' -Password 'P@ssw0rd'
$test = New-DlmDatabaseConnection -ServerInstance 'test01\sql2012' -Database 'Test' -Username 'sa' -Password 'P@ssw0rd' 
$filter = 'C:\Work\MyProductionFilter.scpf' 
New-DlmDatabaseRelease -Target $staging -Source $test -FilterPath $filter

This example demonstrates using a specific filter file (MyProductionFilter.scpf ) to include/exclude database objects when generating the update script, overriding any filter file present in the -Source source. When this update is published, the filters will also be used in pre- and post- deploy checks.

Creating a filter file

To create a new filter file, use SQL Compare. See Using filters.

Didn't find what you were looking for?