Request for parameters



  • There is a request with parameters, but not all the parameters are always present and the result of the request is an empty table, because the parameter is equal to the void and the empty-value records are not available in the table. How do you make sure that if there's no parameter, the request would be made without it.



  • SELECT *
    FROM [Table]
    WHERE (([Field1] = @param1) OR @param1 IS NULL) AND
          (([Field2] = @param2) OR @param2 IS NULL)
    

    etc.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2