December 2013
Intermediate to advanced
1872 pages
153h 31m
English
The CREATE VIEW statement is used to create views with T-SQL. The syntax for the CREATE VIEW statement follows:
CREATE VIEW [ schema_name . ] view_name [ (column [ ,...n ] ) ][ WITH <view_attribute> [ ,...n ] ]AS select_statement [ ; ][ WITH CHECK OPTION ]<view_attribute> ::={ [ ENCRYPTION ] [ SCHEMABINDING ] [ VIEW_METADATA ] }
This statement and the related options are essentially the same in SQL Server 2012 as they were in SQL Server 2008 and prior versions. 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 23.2 shows a sample T-SQL statement for creating a simple view.