Interview Questions

What does this code return? select 6 | 7 Figure it out without running it.

Microsoft SQL Server FAQs


(Continued from previous question...)

What does this code return?
select 6 | 7
Figure it out without running it.

Answer: 7

Explanation: This returns a 7, which is the result of an Inclusive OR between these numbers. These numbers are:
6 - 0110
7 - 0111
If you OR these numbers, you get a 7, which is 0111, all bits with 1s anywhere are returned.

(Continued on next question...)

Other Interview Questions