June 29, 2006 at 2:27 pm
I just had a phone interview and was wondering in someone could give me the answer to this question...
What's the difference between UNION and UNIONALL?
Thanks in advance
-WM
June 29, 2006 at 2:33 pm
From Books Online:
UNION
Specifies that multiple result sets are to be combined and returned as a single result set.
ALL
Incorporates all rows into the results, including duplicates. If not specified, duplicate rows are removed.
June 30, 2006 at 9:26 am
Union does an implicit Distinct on the recordsets being joined, Union All does not - you get All records.
June 30, 2006 at 9:33 am
UNION ALL also does not sort the records in the result set. You get the results from the first query followed by the results of the second query.
So long, and thanks for all the fish,
Russell Shilling, MCDBA, MCSA 2K3, MCSE 2K3
June 30, 2006 at 9:39 am
is the sorting in Union an artifact of the implicit Distinct?
June 30, 2006 at 10:20 am
Yes, and therefore not to be relied on.
Tim Wilkinson
"If it doesn't work in practice, you're using the wrong theory"
- Immanuel Kant
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply