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
SpringTownDBA
SSCertifiable
Points: 6917
More actions
August 9, 2012 at 10:44 pm
#1524200
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.