Home Forums SQL Server 2008 SQL Server 2008 - General Creation of dynamic sql query to create a select statement to pick a unique record RE: Creation of dynamic sql query to create a select statement to pick a unique record

  • Here is another pattern for "catch-all" queries:

    select *

    from t1

    where (@p1 is null or @p1 =t1.c2)

    option (recompile)

    Not sure if better or not for your particular case, you'll want to benchmark it both ways.