Hassan Alrawashdeh Hassan Alrawashdeh - 1 year ago 89
SQL Question

sql value or column values

I work on SQL server 2012, i have a value x and a column y contain some values (y1, y2, ..., yn)

i want to do bitwise or between x and y column

i perform

SELECT x | y
FROM someTable

which returns
x | y1

can someone tell me how to do it please

Answer Source
create function getBitwiseOr(@data int, @k int)
returns int
declare @consolidated int;
set @consolidated = @k
return @consolidated|@data

declare @x int, @k int;
SET @x=inputValue;
SET @k = 0;

select @k = dbo.getBitwiseOr((@x|Yvalue),@k) from HassanData
PRINT @k //this is the consolidated value
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download