I am working with a stored procedure where I want to add or remove WHERE clauses according to the values of a couple parameters.
This is what I've got so far:
WHERE
t.iDdPais = @iIdPais
AND t.iIdRegion = @iIdRegion
AND t.dtFecha BETWEEN @dtStart AND @dtEnd
BUT, if @iIdPais is 0 (which means ALL), I need to remove that clause from the WHERE statement, the same goes to @iIdRegion.