Forum

Please or Register to create posts and topics.

Clean up Un-used sources (SQL)

Hi,

is there an SQL that "finds" sources that are not found used anywhere and removes them? Looking for RM8 or one from RM7 that I might be able to adapt.

Alternately, one that at least finds them so I can review.

thanks, Kevin

 

If you just want sources that don't have citations it would just be a simple select where no citations exist. Source id is still in the main citation table so it's the same for RM7 or 8.

Off the top of my head it's

select * from SourceTable s
left outer join CitationTable c
on s.SourceID = c.SourceID
where c.SourceID is null

It gets a bit more complicated if you want those that have citations but the citations aren't linked to anything. However that only applies to RM8,  since an RM7 citation can't exist without being linked so it's one of those new problems for the future.

kevync has reacted to this post.
kevync

Thanks Pat.  Does this new structure potentially have anything to do with the issue of merging  duplicate citations and causing  issues with GEDCOM etc?

thanks, Kevin