I am creating a stored procedure and have several variables I am passing to the SP. One of the values is @v_mileage. This can contain values such as '9999' or it can contain '9999, 19999, 29999'. I am building a dynamic SQL statement to find records in my DB with the search criteria passed along to the SP.
I need to be able to build a search string to search for one or multiple values for @v_mileage. For instance:
WHERE v.v_mileage <= 9999
WHERE v.v_mileage <= 9999 OR v.v_mileage <= 19999 OR v.v_mileage <= 29999
I need to loop through the @v_mileage and create the search clause above. I am having issues trying to loop through the variable, detect the ", " delimeter, and create the search string.