I am trying to implement a user customizable search and finally I got to the SQL part. The user can select a variable number of criteria and I send everything to the stored procedure in a table-valued parameter. I figured out the logic on how to create the sql string, but I am stuck at the part where I send the parameter. A pseudo code example would be :
foreach parameter in the table-valued parameter
SqlString = SqlString + '@parameter'
ParamList= ParamList + '@parameter'
EXEC sp_executesql SqlString , ParamList, ???
My question is how do I set up the parameters, when I don't know how many they are?