Click to Rate and Give Feedback
MSDN
MSDN Library
SQL Server
SQL Server 2008
Database Engine
Development
 How to: Create UNION Queries (Visua...
Community Content
In this section
Statistics Annotations (0)
Other versions are also available for the following:
SQL Server 2008 Books Online (October 2008)
How to: 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) and Combining Results Sets with UNION

ms190247.note(en-us,SQL.100).gifNote:
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.

  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.

  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.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker