SQL server 2008 CREATE TRIGGER 必须是批处理中的第一条语句
有两张表,student(学生表)books(借书表),我想创建一个删除的触发器,就是学生表中一个学生对应编号删掉后。他的借书信息也相应的删掉,但是提示错误:'CREAT...
有两张表,student (学生表) books(借书表),我想创建一个删除的触发器,就是学生表中一个学生对应编号删掉后。他的借书信息也相应的删掉,但是提示 错误:'CREATE TRIGGER' 必须是查询批次中的第一个语句
表如下及语句如下:
Create trigger todelStudent
On student
for Delete
As
Delete bookid
From books br , Deleted d
Where br.stid=d.stid 展开
表如下及语句如下:
Create trigger todelStudent
On student
for Delete
As
Delete bookid
From books br , Deleted d
Where br.stid=d.stid 展开
展开全部
Create trigger todelStudent
On student
for Delete
As
Delete from books where bookid in (select bookid from Deleted)
更多追问追答
追答
哦,写错了,搞错ID了
这样
alter trigger todelStudent
On student
for Delete
As
Delete from books where stid in (select sid from Deleted)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询