SQL Server Interview Question #65

What is a FULL OUTER JOIN?

Joins, Subqueries, CTEs & Set Operators Mid-Level Intermediate

Detailed Explanation

FULL OUTER JOIN returns matched rows plus unmatched rows from both sides. When a row has no match on the opposite side, columns from that side contain NULL.

It is useful for reconciliation and comparison tasks, such as comparing records from two systems and identifying records that exist in only one source.

Code Example

SELECT a.Code AS SystemACode,
       b.Code AS SystemBCode
FROM dbo.SystemA AS a
FULL OUTER JOIN dbo.SystemB AS b
    ON a.Code = b.Code;