Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
SQL Server
When you create a query, you're retrieving data from a table or other objects structured like tables - views and certain user-defined functions. To work with any of these objects in your query, you add them to the Diagram Pane.
Add a table or table-valued object to a query
In the Diagram pane of the Query and View Designer, right-click the background and choose Add Table from the shortcut menu.
In the Add Table dialog box, select the tab for the type of object you want to add to the query.
In the list of items, double-click each item you want to add.
When you finish adding items, select Close.
The Query and View Designer updates the Diagram Pane, Criteria Pane, and SQL Pane accordingly.
Tables and views are automatically added to the query when you reference them in the statement in the SQL pane.
The Query and View Designer doesn't display data columns for a table or table-structured object if you don't have sufficient access rights to it or if the provider can't return information about it. In such cases, only a title bar and the * (All Columns) check box are displayed for the table or table-valued object.
Add an existing query to a new query
Make sure the SQL Pane is displayed in the new query you're creating.
In the SQL Pane, type a right and left parentheses () after the word
FROM
.Open the Query Designer for the existing query. (You now have two Query Designers open.)
Display the SQL Pane for the inner query - the existing query you're including in the new, outer query.
Select all the text in the SQL Pane, and copy it to the Clipboard.
Select in the SQL Pane of the new query, situate the cursor between the parentheses you added, and paste the contents of the Clipboard.
Still in the SQL Pane, add an alias after the right parenthesis.