Dynamic Search Conditions in T-SQL

An SQL text by Erland Sommarskog, SQL Server MVP.

There is again two versions of this article!

With the query hint RECOMPILE hint now being properly implemented in SQL 2008 (from Cumulative Update 5 for SP1), many of the tricks and tweaks described in the old version are no longer relevant, at the same time there are some new considerations you need to be aware. It was just too much to cram all that into one article.


PS If you wonder about this CU stuff: the new behaviour first appeared in the RTM version of SQL 2008, but Microsoft reverted to the old behaviour in an Cumulative Update and in Service Pack 1, because the original implementation had a bug which could yield incorrect results.