DROP TABLE #NumbersSELECT TOP 1000000 --000 n = ROW_NUMBER() OVER (ORDER BY a.name), CalcValue = CAST(NULL AS BIGINT)INTO #NumbersFROM master.dbo.syscolumns a, master.dbo.syscolumns bCREATE UNIQUE CLUSTERED INDEX CIn ON #Numbers ([n] ASC) -- (1,000,000 row(s) affected)SET STATISTICS IO ONSET STATISTICS TIME ON-- 'Quirky' updateDECLARE @Lastval INT = 0, @CalcValue BIGINTUPDATE #Numbers SET @CalcValue = CalcValue = (@Lastval + n), @Lastval = n-- (1,000,000 row(s) affected) / CPU time = 2968 ms, elapsed time = 3079 ms.-- Table #Numbers... Scan count 1, logical reads 3113, physical reads 6, read-ahead reads 3146, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.-- Recursive CTE;WITH Calculator (n, CalcValue) AS ( SELECT n.n, CalcValue = CAST(n.n AS BIGINT) FROM #Numbers n WHERE n.n = 1 UNION ALL SELECT n.n, CalcValue = n.n + c.n FROM #Numbers n INNER JOIN Calculator c ON n.n = c.n + 1 -- nice --INNER JOIN Calculator c ON c.n + 1 = n.n -- nice --INNER JOIN Calculator c ON c.n = n.n - 1 -- slow --INNER JOIN Calculator c ON n.n - c.n = 1 -- slow --INNER JOIN Calculator c ON c.n - n.n = -1 -- slow )SELECT n, CalcValue FROM CalculatorOPTION (MAXRECURSION 0)-- (1,000,000 row(s) affected) / CPU time = 33297 ms, elapsed time = 36161 ms.-- Table 'Worktable'. Scan count 2, logical reads 6000001, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.SET STATISTICS IO OffSET STATISTICS TIME Off