日期:2014-05-18  浏览次数:20511 次

求助 触发器禁止同时删除2行以上
这个是我的代码 提示 FROM 周围有错误 求解 谢谢了
SQL code
CREATE TRIGGER TRI_NAME_DEL  ON tblStudent 
FOR  DELETE 
AS
DECLARE @towcount int
SET @towcount= COUNT(*) from DELETED 
if @towcount>2
ROLLBACK  TRANSACTION
print 'you cannot delete more than one student at a time!'
END


------解决方案--------------------
SQL code

CREATE TRIGGER TRI_NAME_DEL  ON tblStudent 
FOR  DELETE 
as
begin
DECLARE @towcount int
select @towcount= COUNT(*) from DELETED 
if @towcount>2
begin
  ROLLBACK  TRANSACTION
  print 'you cannot delete more than one student at a time!'
end
END