III.8.3. Using a View

If a view has been created, it can be used to retrieve and modify data. Remember though, the view is only a virtualized table. A view doesn't hold any actual data; instead, it retrieves and modifies data in underlying tables.

The AdventureWorks2008 database includes several views that have already been created. You can create your own views (as shown in the previous section), or you can use the existing views to retrieve and modify data in the underlying tables in the AdventureWorks2008 database.

III.8.3.1. Retrieving data with a view

The AdventureWorks2008 database includes a vEmployee view in the HumanResources schema. It includes name, phone, address information, and more by joining nine different tables.

This data can be retrieved with SQL Server Management Studio (SSMS) or T-SQL statements.

III.8.3.1.1. Retrieving view data using SSMS

Imagine you need to use one of the existing views to retrieve the phone number for Terri Duffy, one of the employees of AdventureWorks2008. The following steps show how to retrieve the information with SQL Server Management Studio (SSMS):

  1. Launch SQL Server Management Studio (SSMS).

    Choose StartAll ProgramsMicrosoft SQL Server 2008SQL Server Management Studio.

  2. On the Connect to Server screen, click Connect.

  3. Using the SSMS Object ...

Get Microsoft® SQL Server™ 2008 All-In-One Desk Reference For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.