June 2015
Intermediate to advanced
1800 pages
70h 6m
English
When you specify UNION in a query, SQL Server merges the result sets, applying one of the merge or concatenation operators with sorting strategies to remove any duplicate rows. Figure 34.25 shows an example of an execution plan for the following UNION query:
SELECT ProductID FROM Sales.SalesOrderDetail sod WHERE sod.OrderQty > 1000UNIONSELECT productID FROM Production.Product p WHERE p.ProductID > 1000
FIGURE 34.25 An execution plan for a UNION query.
You’ll notice this execution plan is similar to the execution plan for the OR strategy where the rows are concatenated and then sorted to remove ...
Read now
Unlock full access