SQLSERVER - Trigger实现级联删除

  • 当删除BG_Group表中的一条数据时,级联删除BG_Purview表中的若干条记录
    CREATE TRIGGER [dbo].[Del_Purview] ON [dbo].[BG_Group]     
    
    AFTER DELETE     
    
    AS   
    
        IF @@ROWCOUNT = 0
    
        RETURN
    
    
    
        DELETE FROM BG_Purview WHERE GroupID IN (SELECT GroupID FROM deleted)
    
    

      

你可能感兴趣的:(sqlserver)