Is there an exclusive OR operator in T-SQL?

前端 未结 3 1663
既然无缘
既然无缘 2021-02-12 15:49

This is my statement

IF (@UserName IS NULL AND @EditorKey IS NULL) OR (@UserName IS NOT NULL AND @EditorKey IS NOT NULL) BEGIN
    RAISERROR (\'One of @UserName,         


        
3条回答
  •  佛祖请我去吃肉
    2021-02-12 16:43

    There's a bitwise XOR, but it's not necessarily what you want:

    http://msdn.microsoft.com/en-us/library/ms190277.aspx

    In your particular case, I find it more immediate to rewrite it like so:

    IF (@UserName IS NULL) = (@EditorKey IS NULL) BEGIN
    

提交回复
热议问题