Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3800818
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:57:09+00:00 2026-05-19T13:57:09+00:00

According this link: Bitwise Operators (Transact-SQL) we can do bitwise operation between binary and

  • 0

According this link:
Bitwise Operators (Transact-SQL)
we can do bitwise operation between binary and int, smallint, tinyint or vice versa.

But how can I make a bitwise exclusive OR in sql server between two binary types?
Or if this is not possible how can I split a binary/varbinary to individual bytes?

The reason I’m asking for this is because I need to xor two numbers bigger than max int value.
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T13:57:10+00:00Added an answer on May 19, 2026 at 1:57 pm

    All comments in code block

    -- variables
    declare @vb1 binary(16), @vb2 binary(16), @lo binary(8), @hi binary(8)
    
    -- 2 guids to compare
    declare @guid1 uniqueidentifier set @guid1 = '96B4316D-1EA7-4CA3-8D50-FEE8047C1329'
    declare @guid2 uniqueidentifier set @guid2 = 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'
    
    -- split every 8 bytes into a binary(8), which is a bigint, the largest size usable with XOR
    select @vb1 = @guid1, @vb2 = @guid2
    
    -- xor the high and low parts separately
    select @hi = convert(binary(8), substring(@vb1,1,8)) ^ convert(bigint, substring(@vb2,1,8))
    select @lo = convert(binary(8), substring(@vb1,9,8)) ^ convert(bigint, substring(@vb2,9,8))
    
    -- the final result, concatenating the bytes using char(8) - binary -> uniqueidentifier
    select 'A', @guid1 union all
    select 'B', @guid2 union all
    select 'A XOR B = ', convert(uniqueidentifier, convert(binary(16),convert(char(8),@hi) + convert(char(8),@lo)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://www.frostjedi.com/terra/scripts/demo/jquery02.html According to this link elements can be moved around by doing $('#container1').append($('#container2')). Unfortunately,
http://www.mapleboutique.com/_blog/maple_blog can someone explain what's going on here? according to this link: http://austinmatzko.com/2007/07/25/internet-explorer-7-float-bug/ –I
I didnt find anything according this issue. Can jaas be used to secure my
According to this post in Recursive Descent vs. LALR , any LALR(k) can be
According to this calculator site ( link text ), when converting 3 from decimal
According to this link: http://forums.silverlight.net/t/20489.aspx encrypting a XAP file is not possible. However, obfuscating
According to this link, gcc provides lots of interesting memory allocators to be used
I have three general JavaEE + Tomcat questions: According to this link ( Using
Hi, According to this link the default values of WCF 4.0 is this :
I am going to consume web service from android according to this link http://jatin4rise.wordpress.com/2010/10/03/webservicecallfromandroid/

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.