During the process of creating automatic statistics, Sql Server internally executes a statement like the following (based on AdventureWorks database)
SELECT StatMan([SC0], [SB0000])
FROM (
SELECT TOP 100 PERCENT [SC0]
,step_direction([SC0]) OVER (
ORDER BY NULL
) AS [SB0000]
FROM (
SELECT [OrderDate] AS [SC0]
FROM [Sales].[SalesOrderHeaderEnlarged] TABLESAMPLE SYSTEM(5.485069e+00 PERCENT) WITH (READUNCOMMITTED)
) AS _MS_UPDSTATS_TBL_HELPER
ORDER BY [SC0]
,[SB0000]
) AS _MS_UPDSTATS_TBL
OPTION (MAXDOP 6)
Paul White has already explained here how the percentage value is calculated. I noticed that if I execute repeatidly the most internal statement, the one with TABLESAMLE, each time it returns a different number of rows, and the reason is that the REPEATABLE clause is not used. As a consequence, dropping and re-creating the statistic several times, I expected to get different statistics, each time, in terms of Rows Sampled and Histogram; instead the statistic is always the same. How can this behavior be explained?