Delete from PDFs
Delete from Versions
Delete from DocumentAudits
delete from Figures  where ROFSTID not in(select rofstid from Associations)
Delete from ROFSTs where ROFSTID not in(select rofstid from Associations)
delete from roimages where rodbid not in(select rodbid from rofsts)
delete from documents where docid not in(select docid from entries)
PRINT 'Phase 1'
delete from tblAnnotations where deletestatus != 0
delete from drousages where docid in(select docid from tbldocuments where deletestatus != 0)
delete from tblEntries where deletestatus != 0
delete from tblDocuments where deletestatus != 0
delete from tblGrids where deletestatus != 0
delete from tblImages where deletestatus != 0
PRINT 'Phase 2'
delete from tblROUsages where deletestatus != 0
delete from tblTransitions where deletestatus != 0
delete from tblParts where deletestatus != 0
delete from tblItems where deletestatus != 0 
 and ItemID Not IN (Select ItemID from Parts)
PRINT 'Purge Contents'
delete from tblContents where deletestatus != 0 
--and ContentID Not IN(Select ContentID from Parts)
--and ContentID Not IN(Select ContentID from Items)
PRINT 'Phase 3' 
delete from AnnotationAudits
delete from ContentAudits
delete from EntryAudits
delete from DocumentAudits
delete from GridAudits
delete from ImageAudits
PRINT 'Phase 4' 
delete from ItemAudits
delete from PartAudits
delete from ROUsageAudits
delete from TransitionAudits
