Use Object Filter

Object Filter enables you to include or exclude database objects in schema comparison results and synchronization. You can filter objects by type, name, or other criteria.

With Object Filter, you can:

  • Select database objects for synchronization.
  • Create or modify filter rules.
  • Open and apply custom filters.
  • Save filters as a .bat file to use it in the command line.

Object Filter

Open Object Filter

Object Filter opens automatically after you run a schema comparison.

If Object Filter is hidden, you can open it in one of these ways:

  • On the Comparison toolbar, click Object Filter.

  • Right-click the schema comparison grid and select Objects Filter.

  • Press Ctrl+L.

Note

Object Filter retains your filter selections even when hidden, and preserves them when you update or rerun a schema comparison.

Object Filter toolbar

Use the toolbar to create custom filters.

Object Filter toolbar

The table describes the toolbar buttons.

Icon Name Description
Open an existing filter Open an existing filter Loads a previously saved custom filter.
Save Save Saves the schema comparison object filter to a .scflt file, either by creating a new file or by updating the current filter file.
Delete the current file Delete the current file Deletes the current user-defined schema comparison object filter file.
Close the Object Filter tree   Closes Object Filter.

Note

The Delete the current file is unavailable for the Nothing Excluded and Custom* filters. The Save button is unavailable only for the Nothing Excluded filter.

Warning

If you reload the same filter, the message This filter has already been loaded. Overwrite? appears. Click Yes to confirm the operation. Click No to cancel.

Filter box

The Filter box shows the available filters:

  • Nothing excluded – The default filter.
  • Custom* – A modified version of the Nothing excluded filter.
  • User-defined filter (for example, MyFilter) – A filter saved as an .scflt file and loaded by a user.

An asterisk (*) in the filter name indicates unsaved changes.

You can select a filter directly from the Filter box.

Select a filter from the Filter box

Object Filter tree

The Object Filter tree lists the database objects on the specified server. Objects appear in alphabetical order.

Object Filter tree

Filter objects by object types

By default, all object types are included in the comparison results and synchronization.

Include object types

To include an object type, select the checkbox for the corresponding type, or click its name.

To include all object types, select the All object types checkbox, or click its name.

Exclude object types

To exclude an object type, clear the checkbox for this type, or click its name.

To exclude all object types, clear the All object types checkbox, or click its name.

Note

Excluding an object or object type removes it from the comparison results and prevents it from being selected for synchronization.

Warning

If an object selected for synchronization references an excluded object, you can include the excluded object later on the Dependencies tab of the Schema Synchronization Wizard.

Save filters

You can save the schema comparison object filter to an XML file with the .scflt file extension.

To save a filter:

1. On the Object Filter toolbar, click Save, then select Save or Save As.

2. In the Save As dialog, specify the file name and select the folder to store the file.

3. Click Save.

The .scflt file stores all object types, their synchronization status (True for included, False for excluded), and any associated filter rules.

File with all object types, synchronization status, and associated filter rules

Warning

Switching to another filter or closing Object Filter discards any unsaved changes, so save your changes before performing these actions.

Create filter rules

In the Filter Editor, you can create:

  • A condition – Defines one or more filter rules within the same group. Rules can be combined using logical operators (And, Or, Not And, Not Or).
  • A condition group – Defines a set of rules combined with a logical operator. Groups can be nested to build complex filters. Depending on the operator, all rules or only some rules are applied.

Create a condition

1. In the Object Filter tree, click Edit Filter for an object type to open the Filter Editor dialog.

2. In Filter rule for, select the object type to which the filter applies, or select All object types to apply the filter to all objects.

3. Select Include objects if (default) to include objects that meet the condition, or select Exclude objects if to exclude objects that meet the condition.

4. To add a condition, click Add a condition.

5. Click the Source Object placeholder and choose the item. They are Operation, Source Object, Target Object, Source Owner, Target Owner, Status, and Type.

6. Click the operator placeholder (default: =) and choose the filter operator for the condition, for example, =, <, <>.

7. Click the value placeholder and choose the value from the list.

8. Click OK to save the changes.

Add a condition in the Filter Editor dialog

Logical operators

In the Filter Editor dialog, click the logical operator placeholder, then choose the operator.

Choose a logical operator

The table describes the logical operators supported in the editor.

Name Description
And Includes or excludes objects when all conditions are true.
Or Includes or excludes objects when at least one condition is true.
Not And and Not Or Reverses the logic of the specified conditions.

Remove conditions

To remove a condition or a condition group, do one of the following:

  • Click Remove a condition for the required condition.

  • Press the Minus Sign key.

Remove condition groups

To remove a condition group, click Remove a condition for the required condition group.

Note

Pressing the Minus Sign key removes only one filter rule in the group.

Reset to default state

To clear all conditions and revert the editor to its default state, in the Filter Editor, click Reset.

Discard changes

To close the dialog without saving changes, click Cancel.

Remove a filter rule

1. In the Object Filter tree, hover over the object whose filter rule you want to remove.

2. Click Clear Filter.

Clear a filter

Filter objects from the command line

You can filter objects from the command line using the following switch:

/filter:<filepath>

where <filepath> is the path to the file that stores the filter.

Schema comparison with the applied filter

To compare objects with the applied filter, use the following command but replace the settings with your actual data:

"C:\Program Files\Devart\dbForge Studio for SQL Server\dbforgesql.com" /schemacompare /compfile:"D:\SchemaComparison\BikeStores (development) vs. BikeStores (production).scomp" /filter:"D:\CustomFilter.scflt"

where:

  • /compfile:"D:\SchemaComparison\BikeStores (development) vs. BikeStores (production).scomp" – Loads the settings from the schema comparison project file (.scomp).
  • /filter:"D:\CustomFilter.scflt" – Applies a custom filter to exclude in or exclude from comparison.

Schema comparison and synchronization with the applied filter

To compare and synchronize objects with the applied filter, use the following command but replace the settings with your actual data:

"C:\Program Files\Devart\dbForge Studio for SQL Server\dbforgesql.com" /schemacompare /compfile:"D:\SchemaComparison\BikeStores (development) vs. BikeStores (production).scomp" /filter:"D:\CustomFilter.scflt" /sync:"D:\BikeStores (development) vs. BikeStores (production).sql"

where:

  • /sync:"D:\BikeStores (development) vs. BikeStores (production).sql" – Specifies the path to the database synchronization script file.

For more information about command-line options, see Additional schema compare arguments.