FileServerDedupe/Generate Egnyte Export.sql
2023-09-15 13:04:44 -06:00

36 lines
967 B
SQL

-- Generate Non-Duplicated PARENT FOLDER List
DROP TABLE DataInventory;
CREATE TABLE DataInventory AS
Select * from (
SELECT SERVER,Parent,
REPLACE(
Parent,
"X:\"," \\mpe.ca\datadrive\") AS UNCPath,
REPLACE(REPLACE(Parent,("X:\" || Server),"/Shared/N-Data"),"\","/") AS EgnytePath,
sum(FileCount), Sum(FileSize), 'Parent' as Source from FolderData
Where Parent != (
SELECT Parent FROM DuplicateList
)
GROUP by UNCPath
)
UNION
SELECT SERVER, Parent,
REPLACE(PATH," X:\","\\mpe.ca\datadrive\") AS UNCPath,
REPLACE(REPLACE(PATH,("X:\" || Server),"/Shared/N-Data"),"\","/") AS EgnytePath,
FileCount, FileSize, 'Project' as Source from FolderData
Where FolderData.Project NOT in (
SELECT A.Project FROM DuplicateList as A)
AND FolderData.Parent in (
Select B.Parent FROM DuplicateList as B
);
delete FROM DataInventory
where Parent in (
select Parent from DataInventory
group by Parent
HAVING count(*) > 1
)
and Source = 'Project';