March 20, 2008 at 3:49 am
Hi,
I have a proc that needs to return a recordset to a web page where the user has selected (via checkboxes) between 0 and 7 values for a field.
The field represents 'stages' of a process - so the user is effectively saying 'show me records at stage 1, 4 and 6' where 1 ,4 and 6 change or may not be there at all.
So datawise we have:
ID Customer Stage
---------------------
1 Fred 1
2 John 4
3 Harry 7
4 Malcolm 6
5 Burt 1
6 George 2
I have a Stage Look up table thus:
StageID Description
--------------------
1 stage 1
2 stage 2
3 stage 3
4 stage 4
5 stage 5
6 stage 6
7 stage 7
Is there a bitwise way of doing this so that the proc can accept just one value to select customers at multiple stages?
Thanks in advance for your help!
March 20, 2008 at 3:59 am
T-SQL has bitwise operations (& | ...) so you could use that, and just specify such an expression in your where clause.
Regards,
Andras
March 20, 2008 at 5:51 am
Thanks - you've confirmed my thoughts!
I've managed to get something like
select * from customers where (stage & intValue) > 0
where the intValue is the user chosen values of the checkboxes.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply