• This is a really useful script, thanks.

    I was using it on a 160,000,000 row table and noticed that I got an arithmetic overflow error. Traced this down to the following part

    , AVG(LEN(' + QUOTENAME(@COLUMN_NAME) + '))

    I cast the result of the LEN as bigint before calculating the AVG to overcome this:

    , AVG(CAST(LEN(' + QUOTENAME(@COLUMN_NAME) + ') AS BIGINT))