Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

what's the meaning of ampersand in select case statement

Posted on 2011-09-29
9
880 Views
Last Modified: 2012-05-12
select name,
       case sysstat2 & 57344
            when 32768 then "datarows"

What's the meaning of the ampersand in front of '57344'

Thanks in advance
0
Comment
Question by:gamjaradio
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 126 total points
ID: 36813581
<% dim iRow
select name,
       case sysstat2 & 57344
            when 32768 then "datarows"

Meaning of this

sysstat2 & 57344   , one of this value either field value of sysstat2 or 57344  is equal to 32768  then "datarows"

in other words condition looks like this

if (sysstat2 = 32768) Or (57344 = 32768 ) then "datarows"
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 125 total points
ID: 36813594
actually,
 case sysstat2 & 57344

is doing a bitwise AND of the 2 values (aka the variable sysstat2 and 57344).
this value will then be compared to the value 32768 , if that matches ....

hope this helps
0
 

Author Comment

by:gamjaradio
ID: 36813625
so, you say....

it compare (sysstat2 == 32768) OR (57344 == 32768) ??
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 126 total points
ID: 36813649
yes
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 125 total points
ID: 36813671
as posted above, I have to disagree ...
0
 
LVL 2

Assisted Solution

by:maneksh
maneksh earned 186 total points
ID: 36814235
Hi,

I am afraid Pratima is wrong.

& is a bitwise operator. it converts the operands into binary and evaluates column by column.

Please follow the link to see details

http://manuals.sybase.com/onlinebooks/group-as/asg1250e/sqlug/@Generic__BookTextView/1719;pt=945

Maneksh

0
 
LVL 2

Assisted Solution

by:maneksh
maneksh earned 186 total points
ID: 36814350
Here in your example 57344 is 1110000000000000
and 32768 is 1000000000000000

some examples of  Values of  sysstat2  that could satisfy the condition are
40959  and  32768

Hope this helps

Maneksh
0
 
LVL 2

Assisted Solution

by:maneksh
maneksh earned 186 total points
ID: 36814459
Hi,

Looking at your query I think you are looking for the lock scheme of a table  which is maitained in sysstat2 table in bit representation.Bit corresponding to 8192 , 16384 and 32768 represents the lock schema and 57344 is the sum of these 3.


Hope I dint confuse

maneksh


0
 
LVL 50

Assisted Solution

by:Lowfatspread
Lowfatspread earned 63 total points
ID: 36816459
its a bitwise operator signifying a logical and operation is performed on the bit patterns of the two expressions

from

msdn
The bitwise & operator performs a bitwise logical AND between the two expressions, taking each corresponding bit for both expressions. The bits in the result are set to 1 if and only if both bits (for the current bit being resolved) in the input expressions have a value of 1; otherwise, the bit in the result is set to 0.

so basically when dealing with flags/indicators stored as a pattern of bits and you wish to test for some specific values
you calculate the numeric value of the combination that you are interested in and have that logically anded with the total option value...

you can then easier test the result to see if the desired set of conditions is present.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question