--find all items that should have a default value set
SELECT * FROM tbItem WHERE ItemID IN(
SELECT ItemID FROM tbDefaultEntityItem WHERE ProcessingTime IS NOT NULL
)


--all items that have a 0 processingtime where it should be null
SELECT e.Entity, i.ItemCode, i.Description,ei.ProcessingTime, ei.* FROM tbEntityItem ei
INNER JOIN tbEntity e ON e.EntityID=ei.EntityID
INNER JOIN tbItem i ON i.ItemID = ei.ItemID
WHERE ei.ProcessingTIme =0 --AND ENTITYID IN (902, 123)
AND ei.ItemID NOT IN (
SELECT ItemID FROM tbDefaultEntityItem WHERE ProcessingTime =0)

--all items that have a null processingtime where it should be set to a value
SELECT e.Entity, i.ItemCode, i.Description,ei.ProcessingTime, dei.ProcessingTime, ei.* FROM tbEntityItem ei 
INNER JOIN tbDefaultEntityItem dei ON dei.ItemID = ei.ItemID
INNER JOIN tbEntity e ON e.EntityID=ei.EntityID
INNER JOIN tbItem i ON i.ItemID = ei.ItemID
WHERE ei.ProcessingTime IS NULL
AND dei.ProcessingTime IS NOT NULL

--to set the incorrect 0 values back to NULL
UPDATE ei 
SET ei.ProcessingTime = dei.ProcessingTime
FROM tbEntityItem ei 
INNER JOIN tbDefaultEntityItem dei ON dei.ItemID = ei.ItemID
WHERE ei.ProcessingTime IS NULL
AND dei.ProcessingTime IS NOT NULL


--set incorrect nulls back to what they should be
UPDATE tbEntityItem 
SET PROCESSINGTIME=NULL
WHERE ProcessingTIme =0 --AND ENTITYID=902
AND ItemID NOT IN (
SELECT ItemID FROM tbDefaultEntityItem WHERE ProcessingTime =0)
