Opetus
Create UNION Queries (Visual Database Tools)
Applies to:
SQL Server
The UNION keyword enables you to include the results of two SELECT statements in one resulting table. All rows returned from either SELECT statement are combined into the result of the UNION expression. For examples, see SELECT Examples (Transact-SQL).
Huomautus
The Diagram pane can only display one SELECT clause. Therefore, when you are working with a UNION query, Query Designer hides the Table Operations pane.
Open a query or create a new one.
In the SQL pane, type a valid UNION expression.
The following example is a valid UNION expression.
SELECT ProductModelID, Name FROM Production.ProductModel UNION SELECT ProductModelID, Name FROM dbo.Gloves;
On the Query Designer menu, click Execute SQL to run the query.
Your UNION query is now formatted by Query Designer.
Supported Query Types
Design Queries and Views How-to Topics
Perform Basic Operations with Queries
UNION (Transact-SQL)
Lisäresursseja
Ohjeet
-
EXCEPT and INTERSECT (Transact-SQL) - SQL Server
Set Operators - EXCEPT and INTERSECT (Transact-SQL)
-
COALESCE (Transact-SQL) - SQL Server
Transact-SQL reference for COALESCE, which returns the value of the first expression that doesn't evaluate to NULL.
-
CASE (Transact-SQL) - SQL Server
Transact-SQL reference for the CASE expression. CASE evaluates a list of conditions to return specific results.
-
Count Rows in a Table (Visual Database Tools)