Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Bitwise And OR operations on bit column's rows

Author  Topic 

Swati Jain
Posting Yak Master

139 Posts

Posted - 2010-01-11 : 08:53:13
select isComplete from task where taskid in (1,2)

taskid isComplete
1 0

2 1

I want the output of the query such as
i should be able to use bitwise operation on column 'isComplete' (in row values)
for row 1 value and row 2 value.


I can not use query like
select (select isComplete from task where taskid=1) &
(select isComplete from task where taskid=2)


as parameters can vary each time like taskid in (1,2,3) also.

How to manage it?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-11 : 09:41:47
do you mean this?

DECLARE @Ret int
SELECT @Ret=COALESCE(@Ret,1) & isComplete
FROM YourTable
WHERE taskid in (1,2,3)
SELECT @Ret
Go to Top of Page
   

- Advertisement -