Skip to content

Latest commit

 

History

History
52 lines (41 loc) · 2 KB

File metadata and controls

52 lines (41 loc) · 2 KB
title Create UNION Queries (Visual Database Tools) | Microsoft Docs
ms.custom
ms.date 06/13/2017
ms.prod sql-server-2014
ms.reviewer
ms.technology ssms
ms.topic conceptual
helpviewer_keywords
queries [SQL Server], types
UNION queries
Select query
combining query results
merged SELECT query [SQL Server]
ms.assetid b5aafb1d-e4ed-4922-b790-56abc5ec551a
author stevestein
ms.author sstein
manager craigg

Create UNION Queries (Visual Database Tools)

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).

Note

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.

To create a Merged SELECT query

  1. Open a query or create a new one.

  2. 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;  
    
  3. On the Query Designer menu, click Execute SQL to run the query.

    Your UNION query is now formatted by Query Designer.

See Also

Supported Query Types (Visual Database Tools)
Design Queries and Views How-to Topics (Visual Database Tools)
Perform Basic Operations with Queries (Visual Database Tools)
UNION (Transact-SQL)