• That's not what I said.

    Unless your database is case-sensitive (is it?), the UPPER is a complete waste of time. The default SQL collations are case-insensitive.

    I also didn't say remove the WHERE clause, returning the entire table isn't a solution. Please read the article I referenced.

    And, in case you missed it:

    In short, remove the UPPER (unless the DB really is case sensitive), rather use the format branch LIKE @Branch OR @Branch IS NULL, and add OPTION(RECOMPILE) to the query.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass