O'Reilly logo

Microsoft SQL Server 2012 Bible by Aaron Nelson, Jose Chinchilla, Patrick LeBlanc, Jorge Segarra, Adam Jorgensen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Basic View

Using SQL Server Management Studio, views may be created, modified, executed, and included within other queries, using either the Query Designer or the DDL code within the Query Editor.

Creating Views Using the Query Designer

Because a view is nothing more than a saved T-SQL SELECT statement, the creation of a view begins with a working SELECT statement. Any SELECT statement, as long as it's a valid SELECT statement (with a few minor exceptions), can be cut and pasted from nearly any other tool into the view designer.

Within SQL Server Management Studio, views are listed in their own node under each database.

The New View command in the context menu launches the Query Designer in a mode that creates views, as shown in Figure 11.1.

Figure 11.1 Creating a view in Management Studio's Query Designer.

11.1

The View Designer mode functions within Management Studio's Query Designer, which is also used to query tables. You can display or edit the actual T-SQL code for the view in the SQL pane. You can add columns to the view by using the Diagram pane, the Grid pane, or the SQL pane. The Add Table feature, available in the context menu or toolbar, can add tables, other views, synonyms, and table-valued functions.

You can add tables or other views to the new view by dragging them to the Diagram pane from the Object Explorer or using the Add Table context menu option.

You can use ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required