I have a stored procedure that has a few lines:
AND ( @StartDate IS NULL OR @StartDate <= r.ReferralDate ) AND ( @EndDate IS NULL OR @EndDate >= r.ReferralDate )
Should it be re-written as:
AND ( r.ReferralDate >= @StartDate or @Startdate IS NULL ) AND ( r.ReferralDate <= @EndDate or @EndDate IS NULL )
I tried it both ways and looking at the execution plans. There is a small difference in estimated number of rows, but other than that I do not see a change, so I assumed that the order in the statement did not matter, but was hoping someone could verify.