III.8.4. Maintaining a View

Things change. People's needs change. And yes, views can change. When you first create a view, it's probably perfect. As people's needs change, though, that view might no longer meet their needs. Often, it takes only a minor change to make it perfect again.

Modifying a view is referred to as modifying the view definition. The view definition is the statement used to create or alter the view, starting with CREATE VIEW or ALTER VIEW. View definitions can be modified with the View Designer or the T-SQL ALTER statement.

To modify a view, you need an existing view. Although AdventureWorks has many views included, you might not want to modify one of them. The following step creates two copies of an existing view that you can then modify in the View Designer and with T-SQL statements.

  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 Explorer, browse to the Databases | AdventureWorks2008 | Views container. Select the HumanResources.vEmployee view.

  4. Right-click the HumanResources.vEmployee view and choose Script View AsCREATE To ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.