This occurs when a legacy Onsite Manager is attempted to be removed from a site. There are two steps involved to remove the Onsite Manager and all associated devices from the site.
Remove the Onsite Manager from the Service Center
declare @siteguid UniqueIdentifier= 'A3177349-ED65-45B5-B235-1374638E3D35'
update site set InstallMachineName = null, InstallMachineGuid = null where guid = @siteguidRestart the VAR.
Have the partner remove the Onsite Manager again.
Clean up after removal
declare @siteguid UniqueIdentifier= 'A3177349-ED65-45B5-B235-1374638E3D35'
update device set ActiveState=2, TimeDeleted=DATEADD(DAY, -400, GETDATE()) where OMGuid=@siteguid and ActiveState=0
Delete from OMCommands where siteguid = @siteguid
exec SC_DeleteDeviceDataA second unexpected Error occurs when attempting to remove
In the event that there is no Onsite Manager device in the database an unexpected error will be displayed.
To repair set a device to be the Onsite Manager
SELECT * FROM device WHERE omguid='A3177349-ED65-45B5-B235-1374638E3D35'
Select the first device ID from the list and list it as the Onsite Manager
UPDATE device SET activestate=1 WHERE deviceid=4153
INSERT INTO DeviceRoleLink(DeviceID,DeviceRoleID) VALUES(4153,1)