Microsoft SharePoint Team Blog
The official blog of the Microsoft SharePoint Product Group
Fundamentals of Creating Views
Visually Creating a View
To create a view, you can use the Object Explorer or a query window. Before starting the view, you would have to specify the table(s) that would be involved. To create a view from the Object Explorer, you can expand the database, right-click Views and click New View. This would open the Add Table dialog box:
The basic functionality is exactly the same as we reviewed in the previous lesson:
To specify the table that would be used as the source, you can click it in the list box of the Tables property page
If you would be using another existing view, from the Views property page, you can click the name of the desired view
If a function would be used to generate the records, you can locate it in the Functions property page. After selecting the source object, you can either double-click it or you can click it once and click Add. In in the previous lesson, we saw that you could add more than one existing table. the same way, you can add more than one view or functions
After selecting the source(s), you can click Close on the Add Table dialog box
After selecting the objects, as we saw in the previous lesson, they would display in the window
As seen in the previous lesson, if you are using more than one table and they are not (yet) related, you can drag a column from one table and drop it on another table to create a JOIN between them
As we saw in previous lessons, to select a column, you can click its check box in the top list. This would display it in the first empty box under the Column column and would add its name to the SELECT statement. Alternatively, you can click an empty box in the Column column to reveal its combo box, then click the arrow of the combo box and select the desired column from the list
After selecting the column, its check box would be checked in the top section of the window, its name would be displayed in the Column column, and it would be added to the SELECT statement. If you know the name of the column you want to add, you can manually type it in the SELECT statement.
To structure of a view can be considered complete when the SELECT statement is as complete as possible. At any time, to test the results of a view, you can run it. To do this, you can click the Execute SQL button . This would cause the bottom section of the view to display the results of the query. Here is an example:
As stated already, one of the reasons for creating a view is to be able to use it over and over again. To achieve this, the view must be saved. Like most objects in SQL Server, a view must have a name and it is saved in its own file. To save a view from the view window, you can click the Save button on the toolbar. You can also attempt to close the window. You would then be prompted to save it. When saving a view, you should give it a name that follows the rules and suggestions of SQL.
Practical Learning: Visually Creating a View
In the Object Explorer, expand the Databases and the RealEstate2 nodes
Right-click Views and click New View
In the Add Table dialog box, double-click PropertyTypes, Properties, and Conditions
Click Close
From the PropertyTypes table, drag PropertyTypeID and drop it on the PropertyTypeID field of the Properties table
From the Conditions table, drag ConditionID and drop it on the ConditionID field of the Properties table
On the tables, select the following fields: PropertyNumber, PropertyType, Condition, City, ZIPCode, Bedrooms, Bathrooms, FinishedBasement, Stories, YearBuilt, and MarketValue
In the Criteria section, click PropertyType and press Tab 6 times. In its Filter field, type Single Family
Press Tab and, in its Or field, type Townhouse
The Name of a View
In our lessons, here are the rules we will use to name our views:
A name will start with a letter. Examples are n, act, or Second
After the first letter, the name will have combinations of underscores, letters, and digits. Examples are n24, act_52_t
A name will not include special characters such as !, @, #, $, %, ^, &, or *
A name will not have spaces
If the name is a combination of words, each word will start in uppercase. Examples are DateHired, RealSport, or DriversLicenseNumber
After saving a view, it becomes part of the Views node of its database: a node would be created for it and its name would appear in the Views node of its database.
source : http://blogs.msdn.com/sharepoint/default.aspx
Minggu, 15 Februari 2009
Langganan:
Postingan (Atom)