Microsoft Press microsoft sql server 2005 PHẦN 5

Tại sao các ÁP DỤNG nhà khai thác cần thiết? Bạn cần các nhà khai thác ÁP DỤNG tương quan kết quả từ phương pháp nút () với kết quả của phương pháp XML khác kiểu dữ liệu được gọi là trong câu lệnh SELECT. Nếu không, bạn sẽ không thể để | Lesson 5 Converting Between XML Data and Relational Data 327 Figure 8-6 shows the result of this query. Figure 8-6 Results of query that uses the nodes method with the CROSS APPLY operator The following code shows how to use the nodes method from an XML type column by using the OUTER APPLY operator SELECT @id int AS ID @name nvarchar max AS NAME count . Employees int AS TOTAL_EMPLOYEE_COUNT . EMPLOYEeS_OLDER_THAN_7 from @ Departments Department T C outer apply . Employees Employee @YearsInRole 7 T2 C Figure 8-7 shows the result of this query. ID NAME TOTAL EMPLOYEE COUNT EMPLOYEES OLDER THAN 7 1 Engineering 6 Empkwees Employee id 3 StartDate 1337-12-1. 2 Tool Design 4 Empkwees Employee id 5 StartDate 1998-01-1. 3 Sales 18 NULL 4 Marketing 3 Empkwees Employee id 2 StartDate 1997-02-2. 5 Purchasing 12 NULL 6 Research and Development 4 NULL 7 Production 173 Emplovees Employee id 1 StartDate 1996-07-3. 8 Production Control 6 NULL 3 Human Resources 8 NULL 1 LI Finance 1 LI NULL 11 Information Services 1 Ũ NULL 12 Document Control 5 NULL 13 Quality Assurance 6 NULL 14 Facilities and Maintenance 7 NULL 15 Shipping and Receiving 6 NULL 16 Executive 2 NULL Figure 8-7 Results of query using the nodesO method with the Outer Apply operator Quick Check Why are the APPLY operators necessary Quick Check Answer You need the APPLY operators to correlate the results from the nodes method with the results of other XML data type methods being called in the SELECT statement. Otherwise you would not be able to call any of the XML data type methods. 328 Chapter 8 Managing XML Data Shredding XML by Using SQLXML SQLXML-annotated XSD schemas enable you to bulk load XML data coming from a file into a database and to transform that data into tabular-relational format when the data is inserted. To bulk load XML data by using SQLXML you must execute the following steps 1. Create the database schema by issuing the required CREATE DATABASE

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
61    293    8    16-04-2024
Đã 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.