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,
Not very succinct, but you could expand out the logic like this:
WHERE
(NOT ((@UserName IS NOT NULL) AND (@EditorKey IS NOT NULL))) AND
((@UserName IS NOT NULL) OR (@EditorKey IS NOT NULL))
Or use the bitwise XOR operator (^):
WHERE
(CASE WHEN (@UserName IS NOT NULL) THEN 1 ELSE 0 END) ^
(CASE WHEN (@EditorKey IS NOT NULL) THEN 1 ELSE 0 END) = 1
You can use a similar approach where there are three or four parameters, and exactly one must have a value:
WHERE
(CASE WHEN (@Var1 IS NOT NULL) THEN 1 ELSE 0 END) +
(CASE WHEN (@Var2 IS NOT NULL) THEN 1 ELSE 0 END) +
(CASE WHEN (@Var3 IS NOT NULL) THEN 1 ELSE 0 END) +
(CASE WHEN (@Var4 IS NOT NULL) THEN 1 ELSE 0 END) = 1