You are hereBlogs / Niral's blog / Get File Sizes of Document from Sharepoint Database
Get File Sizes of Document from Sharepoint Database
This is a simple query to get file sizes from a sharepoint database. I know there are multiple ways of doing this, but I found this the easiest and also the fastest.
select [filename],sum(CAST((CAST(CAST(filesize as decimal(38,2))/1024 As
decimal(38,2))/1024) AS Decimal(38,2))) AS 'Size in MB'
from (select dirname + '/' + leafname as [filename],
size as filesize,
siteid,
webid,
ExtensionForFile
from alldocs unionselect d.dirname + '/' + d.leafname as [filename],
v.size as filesize,
d.siteid,
d.webid,
ExtensionForFile
from alldocs dinner join alldocversions v on d.siteid = v.siteid
and d.id = v.id) as resultsinner join webs s on s.siteid = results.siteid
and s.id = results.webidwhere (filesize is not null
and filesize > 0)and ExtensionForFile not like '%aspx%' -- Not Include Certian File Types
group by
[Filename]
order by 2 desc
- Niral's blog
- 97 reads
Tags
Post new comment