有三个表category news comment category中的id对应new中的caId news中的id 对应comment中的newsId
下面是触发器的内容我看不懂那位帮解释下 越清楚越好:
--赵科制作
--2011 -2- 25
--删除类别触发器
CREATE TRIGGER [trigCategoryDelete] ON [dbo].[category]
instead of DELETE
AS
BEGIN
declare @caId int
select @caId=id from deleteddelete comment where newsId in (select newsId from news where caId=@caId)delete news where caId=@caIddelete category where id=@caId
END
下面是触发器的内容我看不懂那位帮解释下 越清楚越好:
--赵科制作
--2011 -2- 25
--删除类别触发器
CREATE TRIGGER [trigCategoryDelete] ON [dbo].[category]
instead of DELETE
AS
BEGIN
declare @caId int
select @caId=id from deleteddelete comment where newsId in (select newsId from news where caId=@caId)delete news where caId=@caIddelete category where id=@caId
END
解决方案 »
- 急:c#发短信
- 为什么这样不能控制DataGridViewde中的单元格的小数点输出位数
- 远程启动程序或者窗体c#
- data怎么转成string
- beg for a sql sentence using 'alter'to set the existing column as the primarykey
- 变量作用域赋值问题
- 异构系统数据通信讨论
- 有没有安装了最新的 Windows Vista 测试版的?能说说它的最低配置、一般配置、最佳配置是多少吗?
- C#异步委托如何手工结束那个分线程?急!!!!!!!!!!!!!!!
- 关于VisualStdio2008 安装和部署
- 鼠标点击改变图形颜色
- 控件文字或样式左右颠倒问题
//在category表上建立名字为trigCategoryDelete的触发器
CREATE TRIGGER [trigCategoryDelete] ON [dbo].[category]
//指定执行触发器而不是执行触发 SQL 语句,从而替代触发语句的操作。这个一句话说不清,请参考:http://wenku.baidu.com/view/d1cab7e9856a561252d36fe8.html
instead of DELETE
//触发器要执行的工作:
AS
BEGIN
//声明int类型参数caID
declare @caId int
//
select @caId=id from deleted
//删除caID为参数@caID的新闻下的评论
delete comment where newsId in (select newsId from news where caId=@caId)
//删除caID为@caID的新闻
delete news where caId=@caId
//删除id为@caID的类别
delete category where id=@caId
END
如果你在category表执行了删除操作,触发器被触发,触发器执行定义的操作~~~~~~~~~~~~没啥解释的,说起来真绕口~~