This question would be addendum on the last answer in T-SQL stored procedure that accepts multiple Id values
I am passing a few list of ids as a parameter to a stored procedure. Each of them default to null if no data is sent in. For instance, I want food products with ids 1, 2, 5, 7, 20 returned by my stored procedure. I also send in a list of color ids, and production location ids. I am passing in a comma delimited list of these ids. Similar to the last answer in the question referenced above, I create a temp table with the data from each of the parameters. I then want to have a select statement that would be something like this:
SELECT * FROM Candies
INNER JOIN #TempColors
ON Candies.ColorsID = #TempColors.ColorID
INNER JOIN Locations
ON Candies.LocationID = Locations.LocationID
This only works when the parameters are populated and LEFT OUTER JOINS will not filter properly. What is the way to filter while accepting null as a valid parameter?