`

数据库触发器参杂

 
阅读更多
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:  <阿康>
-- Create date: <2009-12-30>
-- Description: <新闻类别表删除触发器>
-- =============================================
CREATE TRIGGER trigCategoryDelete 
   ON  category
   instead of DELETE
AS 
BEGIN
 declare @caid int
 select @caid=id from deleted
 --删除评论
 Delete comment where newsid in(Select id from news where caid=@caid)
 --删除新闻
 Delete news where caid=@caid
 --删除类别
 Delete category where id=@caid
END
GO

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics