Luis Cazares (11/23/2012)
The easiest way is to do it like this
WHERE Oink.[System] like @System + '%'
ANDOink.Stratigrafie like @Stratigrafie + '%'
ANDOink.Ulozeni like @Ulozeni + '%'
AND Oink.DrEvid like @DrEvid + '%'
Or you can add it to the variables before the query if it's easier for you.
I see - it wasn't clear to me that you meant a concatenation. I thought that you simply suggested substituting a single percent for the empty string, and I couldn't see how that would change anything.
But wouldn't this always compare all variables, though? In the syntax with OR, the query engine can see that a variable is empty, thereby satisfying one side of the OR condition, and need not even look in the database. If I use your construct, I think it would require examining every field, every time, to see if there is something in it. Also, it discards any record with nulls in any of the fields. I just tried a small test, and LIKE '%' does not pass a Null.