Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 3.07 KB

File metadata and controls

57 lines (41 loc) · 3.07 KB
title Add Columns to Queries
ms.prod sql
ms.prod_service sql-tools
ms.technology ssms
ms.topic conceptual
helpviewer_keywords
inserting columns
columns [SQL Server], adding
queries [SQL Server], columns
adding columns
ms.assetid 82f3ba72-3d72-4fb1-8179-2a953a782787
author markingmyname
ms.author maghan
ms.manager jroth
ms.reviewer
ms.custom seo-lt-2019
ms.date 01/19/2017

Add Columns to Queries (Visual Database Tools)

[!INCLUDEappliesto-ss-asdb-asdw-pdw-md] To use a column in a query, you must add it to the query. You might add a column to display it in query output, to use it for sorting, to search the contents of the column, or to summarize its contents. You can decide which of the columns you use in the query are included in the results pane when the query is run. For more information see Remove Columns from Query Results (Visual Database Tools).

Note

To view the data type of a column in Query and View Designer; select the table or table-valued object in the Diagram Pane and in the properties window click Column List. Then click the ellipses (...) to open the Column List dialog box.

Wherever you use a column in a query, you can also use an expression that can consist of any combination of columns, literals, operators, and functions.

To add an individual column

  • In the Diagram Pane, select the check box next to the column that you want to include.

    -or-

  • In the Criteria Pane, move to the first blank grid row, click the field in the Column column, and select a column name from the drop-down list.

To add all columns for one table or table-valued object

  • In the Diagram Pane, select the check box next to *(All Columns).

To add all columns for all tables and table-structured objects

  1. Make sure no join lines in the Table Operations Pane are selected.

  2. Right-click in the empty space of the Design window and choose Properties from the shortcut menu.

  3. In the Properties window click Output all columns and choose Yes or No from the dropdown list.

See Also

Remove Columns from Query Results (Visual Database Tools)
Remove Columns from Queries (Visual Database Tools)
Specify Search Criteria (Visual Database Tools)
Summarize Query Results (Visual Database Tools)
Perform Basic Operations with Queries (Visual Database Tools)