-- Notes, Invisible - Convert to General.sql
/* 2014-08-23 Tom Holden ve3meo
GEDCOMs imported from TMG and other programs may have 
notes imported to the RootsMagic primary Name that become 
invisible to the RM 6.3.1.4 user interface. This query
appends each to a general note for the person and deletes
the original. A sister query lists them for inspection.
*/

-- Append non-empty primary name note to person's general note
UPDATE OR ROLLBACK PersonTable 
SET Note = Note || ' ' || (SELECT Note FROM NameTable N WHERE PersonID = N.OwnerID AND n.IsPrimary)
WHERE PersonID IN
(
SELECT OwnerID AS RIN
FROM NameTable 
WHERE Note NOT LIKE '' AND IsPrimary
)
;

-- Delete non-empty primary name notes
UPDATE OR ROLLBACK NameTable
SET Note = ''
WHERE NameID IN
(
SELECT NameID
FROM NameTable 
WHERE Note NOT LIKE '' AND IsPrimary
)
;


