sql server - Stored procedure that accepts multiple id values (where parameter accepts null) -


This question will be on the last answer

Appendix I will list some of the IDs as a stored procedure For a parameter if no data is sent, each of them is the default to clear. For example, I want food products with Eyes 1, 2, 5, 7, 20 by my stored procedure. I also send a list of color IDs, and the production location ID. I am in a comma-delimited list of these IDs, like the last answer in the above question, I create a temporary table with data from each parameter. I want to choose a statement that would be something like this: < Select pre> - Temple callers on the Inner # Campus with candies. Collars id = # tmpcollers Add place to the colorful inner candies. Location id = location Location ID

This works only when the parameters are populated and the left outer Johns will not filter properly. What is the method of filtering when accepting tap as a valid parameter?

You can use

  some status status or @ Ultimate IS NULL   

To join you, it will be returned in all the results if a null was supplied - however as far as I can see what behavior you want when you Null does not specify the passage

(When I say the ultimate means I mean the temporary table column doing this on my phone and it is not easy;))

Edit:

This worked for me:

Like

  - Suppose it's your value string DECLARE @Values ​​varchar (50) - To populate your code table here: The string value is zero when a value is passed INSERT INTO #TempColors blah blah ... - Select the statement Select * Candies from the Candies.ColorsID = # TempColors.ColorID #TempColors on the left where 1 = matter is when Candies.ColorsID is zero and when Candies.ColorsID is not zero And @Values ​​then 0 and 0 end   fil 

This way NULLs will be zero is not zero @Values ​​is zero then 1 has become a non-neural parameter, but one placed for the new module

Comments