Difference between UNION and UNION ALL.

Options
- UNION ALL is no longer supported in sql server 2000 onward
- UNION returns only unique records from both tables. UNION ALL returns all records from both tables
- Both a and b


CORRECT ANSWER : UNION returns only unique records from both tables. UNION ALL returns all records from both tables

Discussion Board
Difference between UNION and UNION ALL

UNION selects only distinct values, whereas UNION ALL selects all values and not just distinct ones. UNION returns only unique records from both tables. UNION ALL returns all records from both tables. UNION is used to combine multiple result sets into one result set and will remove any duplicate rows that exist. UNION ALL is used to combine multiple result sets into one result set, but it does not remove any duplicate rows.

Prajakta Pandit 03-6-2017 12:24 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement