摘要:
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 阅读全文