﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc	db_engine	os_version
2842	Correct Ownership of System Inv Record who do not match the accession's ownnership	Martin Reisinger	Benjamin Haag	"As of 7/20/2023, in NPGSWEB, there are 24,651 accessions whose owner doesn’t match the owner of the system inventory record – and probably should.  

This would be an easy fix for the DBA to run a single script. The script below only identifies the accessions. 

SELECT a.accession_id
FROM accession a
JOIN inventory i ON i.accession_id = a.accession_id 
WHERE i.form_type_code = '**'
AND
a.owned_by != i.owned_by

The following script (per Kurt) could be used to correct existing cases:

UPDATE i 
SET i.owned_by = a.owned_by
FROM accession a
JOIN inventory i ON i.accession_id = a.accession_id AND i.form_type_code = '**'
WHERE a.owned_by != i.owned_by

"	defect	closed	medium		Database, Data Updates	N/A		fixed			N/A	N/A
