Re: Rewrite a WHERE clause



I would keep things simple

if @COUNTY is NULL
--------- scan the table
select * from some_table
else
-------- might use an index
select * from some_table where conty = @county
end if

this way you'll have 2 precompiled plans for 2 different cases

.