sql触发器级联删除

作者:旭江  发布日期:2012-03-20 10:48:25

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:        旭江
-- Create date:
-- Description:    删除类别触发器
-- =============================================


ALTER TRIGGER [dbo].[trigDelete]
   ON  [dbo].[tb_Course]
   instead of DELETE
AS
BEGIN
    declare @ID int
    select @ID = ID from deleted
    --删除评论
    delete tb_Content where OutlineID in (select ID from tb_Outline where CourseID=@ID)
    --删除新闻
    delete tb_Outline where CourseID=@ID
    --删除类别
    delete tb_Course where ID=@ID

END

 

延伸阅读:

Tag标签: sql触发器   级联删除  
  • 专题推荐

About IT165 - 广告服务 - 隐私声明 - 版权申明 - 免责条款 - 网站地图 - 网友投稿 - 联系方式
本站内容来自于互联网,仅供用于网络技术学习,学习中请遵循相关法律法规