试试:
update 物料表 set 单位='无用',默认仓库名称='无用' from 物料表 where (单位 Is null Or 默认仓库名称 Is null) and not exists( select FNumber from t_ICItemCore where t_ICItemCore.FNumber = 物料表.代码)
update 物料表 set 默认仓库名称= c.FName from 物料表 As w Inner join t_ICItemCore As a on w.代码 = a.FNumber Inner join t_ICItemBase As b on a.FItemID = b.FItemID Inner join t_Stock As c on b.FDefaultLoc = c.FItemID where (w.单位 Is null Or w.默认仓库名称 Is null) and b.FDefaultLoc <> 0
还原一个测试库测试