SQL Server New View

Source: Internet
Author: User

I. Creating a view using the SQL Server 2005 database management system

1. Start SQL Server 2005.

2. Locate the student database in the Object Explorer window, open the Student folder, right-click the view item, and select New View from the pop-up submenu. As shown in the following:

3. The Add Table dialog box appears. As shown in the following:

4. In the Add Table dialog box, you can press the CTRL key to select several tables to add, press the Add button, or select a table, click the Add button once, and then click the Close button after selecting all the tables you want to add. The View Designer window looks like this:

Attention:

Click the Show Diagram Pane button in the upper-left corner of the View Designer window to display the table selection area. As shown in the following:

Similarly, click the "Show Criteria Pane" button to display "Column Selection", click the "Show SQL Pane" button, you can display "SQL statement area", click the "Show Results Pane" button, you can display "View results area."

5. If you want to add a new data table, you can right-click the blank space in the table selector and select the Add Table command from the Popup submenu. As shown in the following:

The Add Table dialog box pops up, and you can continue to add the datasheet or view you want to reference for the view.

6. If you want to delete a datasheet or view that you have added, right-click in the table selector to select the data table or view you want to delete, and then select the Remove command from the Popup submenu to delete it. As shown in the following:

Alternatively, use the left mouse button to click on the data table or view you want to delete, and then press the "delete" key directly on the keyboard to delete it.

7. In the Diagram pane, you can create a JOIN between the table and the table ... On "relationship. For example, after adding the data table "Student" and "Chengji", the "Xuehao" field in the "Student" table is the same as the "Chengji" field in the Xuehao table, then there will be a line attached to it, as shown in:

If no line is attached, simply drag the Xuehao field from the Student table to the Xuehao field in the Chengji table. For example, dragging the "xingming" field in the "Student" table to the "xingming" field in the "Chengji" table will appear with a line attached, as shown in:

If you want to remove the connection, right-click on the link and select the "Remove" command from the Popup submenu.

8. In the relationship pane, select the check box in front of the data table to set the fields that the view will output. Also, in the Criteria pane, you can make a selection again on the field you want to output. As shown in the following:

9. In the Criteria pane, you can set the query criteria that you want to filter.

10. In the SQL pane, the SQL statement that appears after the setup is complete, this SELECT query statement is the query statement that the view will store. As shown in the following:

11. After all the query conditions have been set, click the Execute SQL button to execute the SELECT statement to check if it is correct. As shown in the following:

12. If it is running correctly, the output shown in the result pane appears:

13. After the test is OK, click the "Save" button and the "Select Name" dialog box appears, as shown in:

14. Enter the name of the view you want to save, and click the "OK" button.

SQL Server New View

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.