hi alli've had a look around and cant really find anything that covers my issue, I may well be being an idiot but its not something ive had to do before (or if I have then I've dynamically built the sql stmt myself and then run it), so..... what I need to do is base my select stmt around 3 checkboxes, seems simple enough but I only want to use them IF the value is true (1). The columns they refer to are true/false so if they tick 1 box I wuold want the stmt to be:select * from foo where var1 = 1
and if 2 were checked thenselect * from foo where var1 = 1 or var2 = 1
and 3select * from foo where var1 = 1 or var2 = 1 or var3 = 1
I cant just pass the value as I dont want to ever select where a var = 0 (i'll always get all the results).I've tried case stmts but it doesnt seem to like it, the nearest I've got is:...AND ( @VAR = 0 Or ( @VAR <> 0 AND t1.foo = @VAR ))...
which works for just one, but I cant figure out how to get all three working. I know I'll kick myself when I figure it out but its been a long long week and my heads gone all floppy!<edit>I should have said this is in a stored procedure being called from SSRS, otherwise I'd have just built the stmt myself</edit>any thoughts anyonethanksbloom