This is absolutely my last gasp on optional parameters.
My syntax produced 594 logical reads to resolve a query while the equivalent dynamic SQL handled the same issue in six logical reads.
I hereby promise not to write performance analyses in public when I’m packing for vacation.
Repeat after me (although I’m apparently the only one here who needs this reinforcement): dynamic SQL is ALWAYS the one true path in an optional parameter scenario.
Thanks, Adam, for setting me straight.
So much for salvaging my dignity.. 🙂