SQL Server Interview Question #78
What is UNION?
Joins, Subqueries, CTEs & Set Operators Mid-Level Intermediate
Detailed Explanation
UNION combines the results of two or more compatible SELECT statements and removes duplicate rows from the combined result.
Each SELECT must return the same number of columns, and corresponding columns must have compatible data types. Because duplicate elimination can require additional work, UNION ALL is preferable when duplicates do not need to be removed.
Code Example
SELECT Email
FROM dbo.Customers
UNION
SELECT Email
FROM dbo.Suppliers;