SQL Filters for Database Objects

When working with databases that contain a large number of objects, sometimes it is hard to navigate through them and to find the objects that are currently in need. The Filter feature, presented in dbForge Studio for SQL Server, is meant to simplify the work with large databases by filtering database objects in accordance with certain criteria.

A database object is a logical unit that was created in the database and can store data or reference other objects. Database objects include tables, views, stored procedures, triggers, indexes, etc.

A filter is a way to process data based on a specific condition. When applying a filter, you will get only the result that meets the specified criteria. For example, filters can be used to limit the result returned for the database object category or to focus on a specific object. In dbForge Studio for SQL Server, you can apply filters to any object you create in the database.

In this article, we are going to show how to create and delete a filter on a particular example. Suppose we need to filter tables containing the word Employee in their names.

How to create database filter in SQL Server

  1. In Database Explorer, right-click the Tables object category node and select Filter on the shortcut menu.
    Open the Filter Settings dialog from Database Explorer to create a filter in a SQL table
  2. In the Filter Settings (database_object_category) dialog that opens, specify parameters for a filter:
    • Property: Select the property to filter on - Name, Schema, Owner, or Creation Date - from the drop-down list.
    • Operator: Select the way the filter applies the value to the property.
      • For the Name, Schema, and Owner properties the list includes Equals, Not Equals, Contains, Not Contains, Starts With, or Ends With.
      • For the Creation Date, the list includes Equals, Less Then, Less Than or Equal, Greater Than, Greater Than or Equal, Between, Not Between.
    • Value: Enter the value you want to compare to the property.
    • All or Any: Select the option to make a filtered object comply with all or any criteria respectively.
    • The Filter Settings dialog also displays information about the name of the server the database is connected to and the name of the database used.
  3. To apply the filter, click OK.
    Set up a SQL filter for the table in the Filter Settings dialog

After the filter has been applied to the Tables database object category, in Database Exporer, it is labeled as (filtered: number of matching objects). As you can see, all the tables having "Employee" in their names (according to the filter settings) are selected.

Filtered SQL Server database objects are displayed in Database Explorer

Now, let's delete the filter for the database object category we have just created from Database Explorer.

How to delete a SQL filter for database objects

In Database Explorer, right-click the object category node and select Clear Filter on the shortcut menu.

Delete a database object filter from the Tables category in Database Explorer