Sunday, February 19, 2012

How to identify all parameter values selected

I have the SQL query. If the user is selecting all the vendor Numbers available in the vendor number parameter drop down then, I will not include the vendor Number condition in the where portion of the sql query. For that I want to know whether the user has selected all the values available in the drop down. How to identify this?

Have a Default Value in your DropDown, for instance: SELECT ALL with the value of "" VALUE=""

which is basically null. In your where cause use an ISNULL

For instance:

@.COMPANY_ID INT = NULL

Select ID, [NAME], COMPANY_ID FROM EMPLOYEES WHERE COMPANY_ID = ISNULL(@.COMPANY_ID, COMPANY_ID)

Hope this helps.

No comments:

Post a Comment