Using filters in database deployment
Published 28 January 2014
You can use filters to control which objects are deployed when you deploy a database with Deployment Manager. These are the same as the filters used in SQL Compare and SQL Source Control.
Filters need to be included in a database package to be applied when that package is deployed. The filter must be named filter.scpf in the root of the db/state folder in the package.
You can add a filter to a package two ways:
- Use SQL CI (part of the SQL Automation Suite) to create the package and include a filter file in it. This is useful if you want to create an individual package with a filter or automate the package creation.
- Add the filter with SQL Source Control and package it using the Deployment Manager SSMS add-in. This is useful if you want to create multiple packages from SQL Server Management Studio.
Creating a package including a filter file
Requirements
To create a package including a filter file, you must have:
- DLM Automation Suite (previously called the SQL Automation Pack)
- SQL Compare
- Create the filter you want to use. For more information, see Using filters in the SQL Compare documentation.
- Save the filter with the name filter.scpf. For more information, see Saving and deleting filters in the SQL Compare documentation.
- Use SQL CI to create a scripts folder. For more information, see Creating and publishing a database package using the command line.
- Copy filter.scpf file into temporary_folder.
- Publish the package. For more information, see Publish the package with sqlCI.exe.
Adding a filter to a database package with SQL Source Control
Requirements
- Your database must be linked to SQL Source Control. For more information, see Linking a database to source control in the SQL Source Control documentation.
- You must have the Deployment Manager SQL Server Management Studio (SSMS) add-in. For more information, see Installing the SQL Server Management Studio add-in.
- In SSMS, use SQL Source Control to create the filter and commit it to source control. For more information, see Using filters to exclude objects in the SQL Source Control documentation.
- Use the SSMS add-in to publish the latest revision of the database from SQL Source Control. For instructions, see Publishing database packages from SSMS and select SQL Source Control at step 3.
- The filter will be applied when you deploy your package,