TAILIEUCHUNG - Hướng dẫn học Microsoft SQL Server 2008 part 38

Tạo ra quan điểm bằng cách sử dụng thiết kế Query Bởi vì xem là không có gì hơn một tuyên bố được lưu SELECT SQL, việc tạo ra các quan điểm bắt đầu với một câu lệnh SELECT làm việc. Bất kỳ SQL SELECT tuyên bố, miễn là nó là một câu lệnh SQL SELECT hợp lệ (có một vài ngoại lệ nhỏ), có thể được cắt và dán từ công cụ bất kỳ gần như khác vào xem. | Part II Manipulating Data with Select 332 Creating views using the Query Designer Because a view is nothing more than a saved SQL SELECT statement the creation of a view begins with a working SELECT statement. Any SQL SELECT statement as long as it s a valid SQL SELECT statement with a few minor exceptions can be cut and pasted from nearly any other tool into a view. 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 14-1. FIGURE 14-1 Creating a view in Management Studio s Query Designer The View Designer mode functions within Management Studio s Query Designer which is also used to query tables. The actual SQL code for the view is displayed or edited in the SQL pane. Columns may be added to the view by using the Diagram pane the Grid pane or the SQL pane. The Add Table feature Projecting Data Through Views 14 available in the context menu or toolbar can add tables other views synonyms and table-valued functions. Tables or other views can be added to the new view by dragging them to the Diagram pane from the Object Explorer or using the Add Table context menu option. There s a toolbar button and a context menu item to add a derived table to the view but all it does is slightly modify the from clause to create a placeholder for the subquery. The SQL for the subquery is then manually entered in the SQL pane. The Verify SQL Syntax button in the toolbar verifies only the SQL syntax it does not verify the names of tables views or columns in the SQL SELECT statement. To test the view s SQL SELECT statement within Query Designer use the Execute SQL button or F5. This will run the SELECT statement by itself without creating the view. The Save toolbar button actually runs the script to create the view in the database. Note that the view must be a valid error-free SQL SELECT statement in order to be

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.