• Maybe I misunderstood what you're trying to do...

    I assumed that you have a variable that is 'optional', that is the variable may have a value, and if it does, then use that value. If it doesn't have a value, it's null, and then it should behave like there was no variable.. To do that, you may do as I suggested.

    t1.column = COALESCE( @variable, t1.column )

    The idea here is that if @variable is not null, it will be resolved as

    t1.column = @variable

    .. if @variable is null, then it will be resolved as

    t1.column = t1.column

    It looked to me that's what you were trying to do...?

    /Kenneth