Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sql Server FILESTREAM Total File Size

Is there a query that would get me the total file size of the files that are in the FILESTREAM folder on the disk?

like image 817
user55474 Avatar asked Feb 23 '11 03:02

user55474


2 Answers

The following query will return the length in bytes of the filestreamcolumn column:

SELECT SUM(DATALENGTH(filestreamcolumn)) FROM filestreamtable;

Source

like image 175
Remus Rusanu Avatar answered Oct 12 '22 08:10

Remus Rusanu


One disadvantage of Remus' solution is that it will not include the old versions of files that are available for garbage collection. They will no longer be part of logical database, but will still consume disk space until the Filestream garbage collector deletes them.

Starting with Sql Server 2008 R2, you can query the size column of sys.database_files for an approximate size (i.e. disk space used) of a given filestream container.

like image 40
Pawel Marciniak Avatar answered Oct 12 '22 10:10

Pawel Marciniak