Creating Views Using T-SQL

The CREATE VIEW statement is used to create views with T-SQL. The syntax for the CREATE VIEW statement follows:

image

This statement and the related options are essentially the same in SQL Server 2008 as they were in SQL Server 2005 and SQL Server 2000. We first look at a simple example for creating a view with T-SQL and then delve into several other examples that utilize the view attributes. Listing 27.2 shows a sample T-SQL statement for creating a simple view.

Listing 27.2 Creating a Simple View with T-SQL

image

There are several ...

Get Microsoft® SQL Server 2008 R2 Unleashed now with O’Reilly online learning.

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