XOR?

  • Man, it's been a while since I posted!

    Simple question: is there such a thing as an exclusive OR in T-SQL?

    I didn't see anything in BOL, so I figured I'd ask the gallery to see if anyone knew anything about this.

    +--------------------------------------------------------------------------------------+
    Check out my blog at https://pianorayk.wordpress.com/

  • I believe that you're looking for "^" (bitwise Exclusive OR) operator.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Thanks for the assist; unfortunately, it didn't work for me. (Sorry, I should have been a little more specific; my fault.)

    Here's my scenario: I wrote a SP, and I'm struggling with the WHERE condition logic. I was just thinking how much easier my life would be if there was an XOR or its equivalent.

    If anyone reading this is curious about what I'm trying to solve, I'll create a new topic (in which it's more appropriate) and post a link to it.

    +--------------------------------------------------------------------------------------+
    Check out my blog at https://pianorayk.wordpress.com/

  • You could replicate the functionality I guess with something like:

    WHERE (Col1=X OR Col2=Y) AND NOT (Col1=X AND Col2=Y).

  • HowardW (6/3/2010)


    You could replicate the functionality I guess with something like:

    WHERE (Col1=X OR Col2=Y) AND NOT (Col1=X AND Col2=Y).

    I thought about that, but that could get messy.

    I'm working on putting together some sample data to post. As soon as I'm done, I'll start a new thread and post a link to it.

    +--------------------------------------------------------------------------------------+
    Check out my blog at https://pianorayk.wordpress.com/

  • As promised, here's the link to my new thread.

    +--------------------------------------------------------------------------------------+
    Check out my blog at https://pianorayk.wordpress.com/

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply