xhr489
xhr489

Reputation: 2319

Filter tables in SSMS with two conditions

Is it possible to filter e.g. tables in Object Explorer in SSMS based on a or condition. That is I want to filter all tables which either have "this" or "that" (see below) enter image description here

Upvotes: 4

Views: 2965

Answers (1)

Preben Huybrechts
Preben Huybrechts

Reputation: 6111

You can only do this using queries.

Examples

USE [YourDatabase]

-- Get all tables starting with a or b, inside schema dbo.
SELECT *
FROM sys.tables t 
WHERE (t.Name LIKE 'A%'
OR t.Name LIKE 'B%')
AND t.schema_Id = schema_id('dbo')

-- Get all Tables, views, Stored procedures, and inline table valued functions starting with A

SELECT *
FROM sys.objects o
WHERE o.Name LIKE 'A%'
AND o.type IN (
    'U' -- User table
    , 'V' -- Vieww
    , 'P ' -- Stored Procedure
    , 'IF' -- Inline Table valued Functions
)

Upvotes: 1

Related Questions