我在一个主表里定义了一个触发事件,我的目的是在删除主表的时候把从表删除!!!
CREATE TRIGGER yzl2 ON [dbo].[student_cjbb]
FOR DELETE
ASdeclare
@id int
select @id=id from deleted
delete from student_cjbb2 where student_cjbb_id=@id
delete from student_achievement where student_cjbb_id=@id
delete from student_achievement2 where student_cjbb_id=@id
delete from grade_Stat where student_cjbb_id=@id
但现在出现了一个问题,就是如果是单独一条条记录删除的话那么从表也会跟着删除例如
delete from student_cjbb where id=1 如果是这样就没问题!!
但如果是一次删除多条记录的话,那么他的从表只会删除第一条记录所对应的id! 例如
delete from student_cjbb where id in (1,2,3,4)
那么他的从表只会删除对应id为1的记录,而2,3,4的记录去没删除,这是为何,请各位大哥帮看看,小弟万分感谢!!!
CREATE TRIGGER yzl2 ON [dbo].[student_cjbb]
FOR DELETE
ASdeclare
@id int
select @id=id from deleted
delete from student_cjbb2 where student_cjbb_id=@id
delete from student_achievement where student_cjbb_id=@id
delete from student_achievement2 where student_cjbb_id=@id
delete from grade_Stat where student_cjbb_id=@id
但现在出现了一个问题,就是如果是单独一条条记录删除的话那么从表也会跟着删除例如
delete from student_cjbb where id=1 如果是这样就没问题!!
但如果是一次删除多条记录的话,那么他的从表只会删除第一条记录所对应的id! 例如
delete from student_cjbb where id in (1,2,3,4)
那么他的从表只会删除对应id为1的记录,而2,3,4的记录去没删除,这是为何,请各位大哥帮看看,小弟万分感谢!!!
解决方案 »
- WindowMediaPlayer在分線程里無法播放
- 有关fastreport动态取得数据源的问题,急,高分求救!!!
- 【求助】请问如何能得到不规则的窗体形状,或者是不规则的容器形状?
- 女生就不能学编程吗?
- 如何对DBGrid中的内容进行打印
- pcomm开发拨号程序。利用调制解调器通讯,急!
- 高性能web服务器大征集。Delphi.Socket高手QQ大征集。
- paradox的主从表,不能实现一对多吗,就人命呀!
- 在Activeform中我可以执行应用程序了但是需要配置ie 的安全设置请问有什么办法可直接已运行ActiveForm程序呢????
- How can I help you for your website spread quickly?dd
- 自定义组件的可见性实现?
- SavePictureDialog1.FileName 如何设置后缀
其他类似