03 2011 档案
摘要:当跨assemblies的时候要特别注意两者的区别, 请看这篇文章if the scope of your constant is limited to just one assembly, class, or smaller (you can define a const inside a method), this is not a big deal. However, if the const is visible outside the assembly it is defined in, we must be wary! Because the const’s value is su
阅读全文
摘要:在sqlserver中可以这样显示分组前N个成员, 关键在row_number, partitionselect * from (select schoolmember_id, row_number() over(partition by school_id order by schoolmember_id ) as number from schoolmember) as awhere a.number < 3
阅读全文
摘要:private static int BinarySearch(T[] array, int index, int length, T value){ int lo = index; int hi = index + length - 1; while (lo <= hi) { int i = lo + ((hi - lo) >> 1); int order; if (array[i] == null) { order = (value == null) ? 0 : -1; } else { order = array[i].CompareTo(value); } if (o
阅读全文
摘要:declare @text nvarchar(500) ,@delimiter nchar(1)set @text = '1,2,3'set @delimiter = ',' set @text = @text + @delimiter;WITH CSV([index], [comma_index])as(select [index] = 1, [comma_index] = CHARINDEX(@delimiter, @text) union allselect [index] = [comma_index] + 1, [comma_index] = CHAR
阅读全文
摘要:通过SqlServer的Common Table Expressions (CTE)可以进行递归计算。参见Using Common Table Expressions 和 Recursive Queries Using Common Table Expressions通过CTE计算FibonacciWITH Fib(a, b)AS(SELECT 0,1 UNION allSELECT b, a+b FROM Fib WHERE b < 10)SELECT * FROM Fib
阅读全文