TAILIEUCHUNG - Microsoft SQL Server 2005 Developer’s Guide- Part 14

Microsoft SQL Server 2005 Developer’s Guide- P14:SQL Server 2005 is a feature-rich release that provides a host of new tools and technologies for the database developer. This book is written to help database developers and DBAs become productive immediately with the new features and capabilities found in SQL Server 2005. | Chapter 3 Developing CLR Database Objects 109 The Merge method is used when the aggregate is processed in parallel which typically won t be the case for most queries. If the Merge is called its job is to import the current aggregation values from the parallel instance. You can see here that it does that using two helper methods that essentially export the values in the m_HighValue and m_LowValue variables. These values are compared to the existing values and if they are higher or lower they will replace the current values in m_HighValue and m_LowValue. The Terminate method is called once after all of the results have been processed. For this example the Terminate method simply subtracts the lowest value found from the highest value found and returns the difference to the caller. Deploying the Aggregate After compiling the class into a DLL you can import the DLL as a SQL Server assembly using either the Visual Studio 2005 Deploy option or manually using the CREATE ASSEMBLY statement and CREATE AGGREGATE statement as is shown in the following listing create assembly MaxVariance from C temp go CREATE AGGREGATE MaxVariance @maXVar int RETURNS Int EXTERNAL NAME MaxVariance. go Like the earlier examples this listing assumes that has been copied into the c temp directory on the local SQL Server system. In the CREATE AGGREGATE statement and the EXTERNAL NAME clause the first part of the name specifies the assembly that will be used and the second part of the name identifies the namespace and class. Here all of these values are named MaxVariance. Using the Aggregate You can use the aggregate just like SQL Server s built-in aggregate functions. One small difference is that the UDAGG needs to be prefixed with the schema name to allow the system to locate it. The following line illustrates using the MaxVariance Aggregate SELECT MinQty FROM 110 Microsoft SQL Server 2005 Developer s Guide

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.