• You have two possibilities. The first one is using IF statements, each with their own query. This is OK if you only have a few parameters, but the number of combinations grows very quickly.

    Another possibility is to change the query to take left out parameters into account.

    In your example, the query would look like :

    
    
    SELECT *
    FROM TRANS
    WHERE Transid = IsNull(@param1, Transid)
    AND Custid = IsNull(@param2, Custid)
    AND Trandate Between IsNull(@param3, Trandate) AND '7/1/2003'