Solved

what's the meaning of ampersand in select case statement

Posted on 2011-09-29
9
889 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
[X]
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
  • 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
export sql server dbs 2 26
store vs query adhoc - no show rows 4 37
Search Text in Views 2 27
Datatable / Dates ? 4 29
I have a large data set and a SSIS package. How can I load this file in multi threading?
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

739 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