• Admittedly, getting it right may have biased my opinion, but I have to say that this is possibly the best QotD I've tried so far so please, more like this Hugo! 🙂

    I would also mention that having done the calculations by hand, I double-checked them by running the code (I used the numbers 1 to 1000000 from a tally table in another DB I keep on hand for the PK column values) then using this query:

    SELECT SUM(page_count)

    FROM sys.dm_db_index_physical_stats

    (

    DB_ID(),

    OBJECT_ID('DemoTable'),

    NULL,

    NULL,

    'DETAILED'

    );

    Since you specified SQL Server 2005 and up in the question, I figured it was a good way of highlighting how the Dynamic Management Views can help us work these things out.