At the lowest level, all views are based on one or more physical database tables. (You can create views based on other views. However, at some point, one of the views in the chain has to be based on an actual database table.) Therefore, to see how you can use the Create View Wizard to create a view, you must start by deciding on the data you want to display. Suppose, for example, that you want to create a view based on the data in the PRODUCTION table shown in Figure 65.1.
PRODUCTION table | ||||
---|---|---|---|---|
Rep_ID | Call | Appointments | Sales | Deliveries |
1 | 100 | 4 | 3 | 2 |
2 | 255 | 7 | 4 | 4 |
3 | 750 | 12 | 6 | 5 |
4 | 400 | 15 | 9 | 7 |
5 | 625 | 10 | 8 | 6 |
6 | 384 | 11 | 6 | 4 |
7 | 295 | 17 | 4 | 1 |
To use the Create View Wizard to create a view that displays data from a single table, perform the following steps:
-
Start the Enterprise Manager by clicking your mouse on the Start button. When Windows displays the Start menu, move your mouse pointer to Programs, select Microsoft SQL Server 7.0, and then click your mouse on Enterprise Manager.
-
To display the list of SQL servers, click your mouse on the plus (+) to the left of SQL Server Group.
-
Click your mouse on the icon for the SQL Server with the database in which you wish to create the view. For example, if you want to create a view in a database on a server named NVBIZNET2, click your mouse on the icon for NVBIZNET2.
-
Select the Tools menu Wizards option (or click your mouse on the Wizards button, the magic wand on the Standard Toolbar). Enterprise Manager will display the Select Wizard dialog box so that you can select the wizard you want to use.
-
Click your mouse on the plus (+) to the left of Database to display the list of database object wizards.
-
Click your mouse on Create View Wizard to select it, and then click your mouse on the OK button. Enterprise Manager will start the Create View Wizard, which displays its "Welcome to the Create View Wizard" screen.
-
Click your mouse on the Next button. The Create View Wizard will display the Select Database dialog box.
-
Click your mouse on the drop-down list button to the right of the Database Name field to display the list of databases on the SQL Server you selected in Step 3.
-
Click your mouse on the database in which you wish to create the view. For the current example, click your mouse on SQLTips to select the SQLTips database.
-
Click your mouse on the Next button. The Create View Wizard will display a Select Tables dialog box, similar to that shown in Figure 65.2.
Figure 65.2: The MS-SQL Server Create View Wizard's Select Tables dialog box
-
Click your mouse on the check boxes of the tables whose data you want to include your view. For the current example, click your mouse on the check box for the PRODUCTION table until the check mark appears.
-
Click your mouse on the Next button. The Create View Wizard will display a Select Columns dialog box, similar to that shown in Figure 65.3.
Figure 65.3: The MS-SQL Server Create View Wizard's Select Columns dialog box
-
Click your mouse on the check boxes of the columns you want to display. For the current example, select: PRODUCTION.REP_ID, PRODUCTION.CALLS, PRODUCTION. SALES, and PRODUCTION.DELIVERIES.
No comments:
Post a Comment