Dynamics GP Install/upgrade failed SyCompanyImages

SyCompanyImages

install upgrade failed syCojmpanyImages

Interesting issue with upgrading Microsoft Dynamics GP.

The upgrade stopped at the above step

Microsoft Dynamics GP Utilities install/upgrade failed
syCompanyImages

Turns out this was linked to deleting companies from this instance of GP, and the delete leaving orphaned records in the DYNAMICS..SyCompanyImages table.

The syComanyImages table holds the images used by word template reports, that are uploaded using the form below:

Reports>>Template Configuration>>[Images] button

Company Images Window Dynamics GP

There was an orphaned record from the deleted company in the table that is used to back that form. The extra record was removed using the following script:

DELETE FROM Dynamics.dbo.syCompanyImages  
WHERE (RELID/65536) NOT IN  
(  
SELECT (CMPANYID) FROM  Dynamics.dbo.SY01500 )  
)   

Note that I don’t understand how this table works entirely, other than its holding a binary blob of the image, that is referenced back in this bizarre /65536 formula. I would check what records will be deleted before actually running this script.

Note that It is important to have ran ClearCompanys.sql - Script that will clear out all entrys in the DYNAMICS database referencing databases that no longer exist on the SQL Server, BEFORE running the above script. This is to make sure that SY01500 only has companies that have databases associated with them.