框架-下级已存在,上级不可删除

主从表或者关联分类表存在下级使用上级数据的,不可删除判断条件
if exists (select * from TrainErp_Product_ProductTopic
                 where ProductLevelInfoCode in (select ProductLevelInfoCode from TrainErp_Product_ProductLevelInfo
                 where ProductLevelCode in(select ProductLevelCode from TrainErp_Product_LevelAfter
                 where ProductCode in(select ProductCode from TrainErp_Product_Product
                 where ProductCode=@pi_ProductCode
                ))))
        begin
            set @po_status = 200
            set @po_RetValue='当前产品已存在课题,请先删除课题信息!'
        end

原文地址:https://www.cnblogs.com/howie/p/4999671.html