Query Sharepoint Content DB for Doc Library Sizes and Number of versions


SELECT v.[id],

       d.dirname,

       Count(v.[version]) MaxNumberOfVersions,

       Sum(v.[size])      TotalDocLibSize,

       Max(v.[size])      LargestDocSize

FROM   [dbo].[alldocversions] v

       JOIN [dbo].alldocs d

         ON v.id = d.id

GROUP  BY v.id,

          d.dirname

ORDER  BY 4 DESC