• Thanks, it's an interesting approach.

    Just one question: Have you tested index use with this approach?

    The reason I ask is that some years back I would construct WHERE clauses as follows:

    WHERE

    --If a param is not null, then it will be used as a filter

    (@Param1 IS NULL OR COL1 = @Param1)

    AND (@Param2 IS NULL OR COL2 = @Param2)

    AND (@Param3 IS NULL OR COL3 = @Param3)

    --etc.

    I discarded the approach because the optimiser was incapable of interpreting the pattern to choose appropriate indexes.