• [font="Comic Sans MS"]Went for these links you provided and played around a bit with the ROW UNBOUNDED part I had neglected.

    [/font]

    [font="Courier New"]DECLARE @Tbl TABLE

    (

    pk BIGINT not null primary key identity, -- BIGINT necessary to avoid overflows

    N int,

    NSum BIGINT

    )

    IF OBJECT_ID('tempdb.dbo.#T2', 'U') IS NOT NULL

    DROP TABLE #T2

    -- Populate table with 1 million rows

    INSERT INTO @Tbl (N) SELECT TOP 1000000 1 FROM syscolumns a CROSS JOIN syscolumns b

    -- Use a temp table to store results to allow viewing the results on last rows without

    -- sending to the results window the preceeding 1 million – 20 rows, takes too long

    SELECT *

    INTO #T2

    FROM (

    SELECT pk, SUM(pk) OVER (ORDER BY pk ROWS UNBOUNDED PRECEDING) AS NSum FROM @Tbl

    ) AS x

    SELECT TOP 20 * FROM #T2 ORDER BY pk DESC --Last line NSUM: 500,000,500,000

    [/font]

    [font="Comic Sans MS"]Notes:

    1.Using[/font] [font="Courier New"]ROWS UNBOUNDED [/font][font="Comic Sans MS"]took 4 seconds for 1 million rows. 10 million rows took 37 seconds

    2.NOT Using[/font] [font="Courier New"]ROWS/RANGE UNBOUNDED [/font][font="Comic Sans MS"]took 22 seconds to run for 1 million rows.

    3.Using[/font] [font="Courier New"]RANGE UNBOUNDED [/font][font="Comic Sans MS"]took 22 seconds to run for 1 million rows.[/font]