Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

XOR Function - SQL Server

RSS
Modified on Wed, Oct 22, 2008, 9:26 PM by Administrator Categorized as SQL Server
The following SQL statement demonstrates a technique for calcuating an XOR value.

declare 
     @a bit
    ,@b bit

select
     @a = 0
    ,@b = -1

select result = 'Exactly one is null? ' + 
    case coalesce(abs(sign(@a)),-1) * coalesce(abs(sign(@b)),-1) 
    when -1 then 'TRUE' 
    else 'FALSE' 
    end

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.