You are viewing limited content. For full access, please sign in.

Question

Question

List of files and size

asked on April 8, 2024

Is there a report or SQL table that lists all files and their size?

0 0

Replies

replied on April 8, 2024

I am guessing you are referring to files in the repository?

0 0
replied on April 8, 2024

Hi Blake,

Yes I want to be able to determine the average size and also see how many large files get uploaded. 

0 0
replied on April 8, 2024

If it is an electronic file, the size information is kept in the toc table. If it is a native file, the size is stored in the doc table. In the doc table each row is a page, so you would need group the rows by tocid.

0 0
replied on April 8, 2024

Will it have video file size?

0 0
replied on April 8, 2024

A video would be considered an electronic file, so that would be in the toc table.

0 0
replied on April 8, 2024

Do you know if the  size is in bytes?

0 0
replied on April 8, 2024

Yes

1 0
replied on April 8, 2024 Show version history

If you're adding things up across the whole table, don't forget to convert it to bigint (as the columns are int and the sum can easily be over 2 billion).

For ex, aggregate size of all e-docs:

select sum(convert(bigint,edoc_size)) as EDocTotalBytes from toc

 

2 0
replied on April 8, 2024 Show version history

Blake this has been very helpful!  Is there a table that shows the path? 

0 0
replied on April 9, 2024 Show version history

The path is built from the toc table.  Each entry (other than the ROOT FOLDER) has a value in the parentid field that refers to the tocid of another entry, which is the parent folder of the entry.  Therefore, you can determine the path by looking at the parent of the entry, and its parent, and its parent, etc. until you get to the ROOT FOLDER entry.  The ROOT FOLDER entry should have a tocid=1.

EDIT TO ADD: Here's a recursive query to determine the path of items in the toc table: 

--Recursive Common Table Expression to Return List of Entries and Their Paths
WITH recursive_cte AS (
  
  --Anchor query that returns the ROOT FOLDER entry
  SELECT
    toc.tocid,
    toc.name,
    toc.parentid,
    0 as level,
    CAST(toc.name as VARCHAR(MAX)) as path
  FROM toc
  WHERE parentid IS NULL AND name = 'ROOT FOLDER'

  --Recursive Join to Other Entries
  UNION ALL

  --Recursive query for each entry
  SELECT
    toc.tocid,
    toc.name,
    toc.parentid,
    level + 1,
    CAST(recursive_cte.path + ' > ' + toc.name as VARCHAR(MAX))
  FROM toc
  INNER JOIN recursive_cte ON recursive_cte.tocid = toc.parentid
  --This Break Condition (WHERE Statement) limits the results.
  --For this example, it only grabs entries with an entry ID
  --of 1000 or lower.  Removing this WHERE statement will return
  --all entries in the toc table (there could be thousands, 
  --millions, or even more - use with caution).
  WHERE toc.tocid <= 1000
)

--Return all results from the recursive query above.
SELECT * FROM recursive_cte

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.