Using the CLR to write functions: scalar functions, table-valued functions are well understood, if the aggregate function is not so well understood,
Here is a description of the CLR function, in fact, the key is to explain the aggregate function
Using the CLR to write aggregate function keys is to understand how the CLR interacts with SQL for data,
The first step: the function of the functions in the aggregation function
Step Two: aggregation function call order
Step three: The number of times the aggregate function is called in the actual SQL
Note: When you are transferring CLR variable data, the data type is an object or list, please convert when the Write method is good, if the terminate conversion will give an error.
The correct conversions are as follows:
/// <summary> /// Write /// </summary> /// <param name= "W" ></param> Public void Write (System.IO.BinaryWriter W) //2 { w.write (string . Join (Separate_, Valuelist.orderby (TT = Tt.orderno). Select (TT = tt.itemstring). ToArray ())); W.write (Separate_); }
PCB MS SQL CLR Aggregation functions (function, invocation order, number of calls) CLR description