My goal here is to create a dynamic 'report builder' application without creating a string to pass to the server as my sql query. I am wondering if there is a good (or any) way to make a where clause that has an unknown amount of possibilities. The best way I can explain is with this query...
SELECT *
FROM table
WHERE column1 = 'a' OR column1 = 'b' OR column1 = 'c' OR column1 = 'd' ...
Basically just an unknown amount of OR
s. I know the following query is in no way close to correct, but here's what I am looking for an idea of:
@ColValues = 'a || b || c || d ...'
SELECT *
FROM table
WHERE column1 = @ColValues;
Essentially I want the user to pass only one variable for column1
and still be able to return results based on multiple where
clauses. Normally the IN
operations would solve my issue, problem is with this application I have no clue how many items will need to be in the final where clause. Could be 1 value, could be 50. Also needs to be passed from a C# parameter to a T-SQL stored procedure.