Adding Tables
When you create a query, you are 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.
Note For information about adding tables or objects structured like tables from different data sources while working with SQL Server, see Query Designer Considerations for SQL Server Databases.
To add a table, view, or user-defined function to the query
- In the Diagram pane of the Query Designer or 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, click Close.
The Query Designer updates the Diagram pane, Grid pane, and SQL pane accordingly.
Alternatively, you can drag objects onto the Diagram pane. You can drag a table, view, or user-defined function from the SQL Server Enterprise Manager.
You can also drag columns or tables from the Database Designer or paste them from the Clipboard.
Tables and views are automatically added to the query when you reference them in the statement in the SQL pane.
The Query Designer will not display data columns for a table or table-structured object if you do not have sufficient access rights to it or if the
To add an existing query to a new query
- Make sure the SQL pane is displayed in the new query you are 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 are including in the new, outer query.
- Select all the text in the SQL pane, and copy it to the Clipboard.
- Click 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.