ASP.Net/C# - Dynamic Where Clause Should be Easy
Posted on 2006-04-20
Hello all. I have a dynamic SQL string I am creating and the Where Clause has an IN in the statement. What I need to do is some of the parts in this IN statement can be blank "". I need to omit those in the IN statement and only have the IN statement run with parts that have a value. For example,
Where part_num IN ('" + partNum1 + "','" + partNum2 + "','" + partNum3 + "','" + partNum4 + "','" + partNum5 + "')
partNum4 could be blank so I need to leave that out. Any idea on how to easily build this with something clean. Thanks all.