Doing a comparison of column pairs, trying to find any that don't match
SELECT
RecID,
Field1,
Field2
FROM
TestTable
WHERE
Field1 != Field2
However I want to include Nulls in my check. Null in both columns is valid, however Null in one column and not in the other is invalid so needs to be included in the output
SELECT
RecID,
Field1,
Field2
FROM
TestTable
WHERE
(Field1 != Field2)
OR (Field1 IS NULL AND Field2 IS NOT NULL)
OR (Field1 IS NOT NULL AND Field2 IS NULL)
Is this the best way to write this, or is there a tidier/better way to do Null
/Not Null
comparison?