Working with Views


A view can be thought of as either a virtual table or a stored query. The data accessible through a view is not stored in the database as a distinct object. What is stored in the database is a SELECT statement. The result set of the SELECT statement forms the virtual table returned by the view. A user can use this virtual table by referencing the view name in Transact-SQL statements the same way a table is referenced.

Adding new View

To create a new view, you can:

 

Then, the Enter View Name dialog box appears (see Figure 1).  Enter the name of the view you want to create and click on the OK button. The View Edit window with the default view script appears (see Figure 2). You can modify the script for the view. After finish editing the script you can click on the Check Syntax button at the bottom of the dialog.  If there is not syntax error in the script, you can click on the Save button to save the view scripts into SQL Server.

 

 

Figure 1  Enter View Name Dialog

 

Editing a View


Only the views that have been checked out by you (in Red color) and the views that are created by you but have not been checked in (in Blue color) can be edited. For views that are checked out by others or not checked out (in Black color), you can view/browse the script but not make any change. To edit/browse a view, you can:


 

Figure 2  Edit View Dialog


The SQL Editor is full syntax colored to improve the readability of complex statements. It also features all needed editing functionality. When you want to check the syntax of the script you entered in the Edit View dialog box, click on the Check Syntax button at the bottom of the dialog. If there is no syntax error, you can click on the Save button to save the change.

 

Deleting a View


To delete a view, you can:

 

Renaming a View


This operation allows you to rename a view.

 


SQLSourceSafe, 2003-2006 © Copyright, Best SoftTool, Incorporated