我想在SELECT
执行删除查询时使用触发器从 a 中删除所有行,而不删除最后返回的行。
此触发器不起作用,因此非常感谢任何帮助。
CREATE TRIGGER TR_StergereOfertaSpeciala
ON OferteSpeciale
INSTEAD OF DELETE
AS
DECLARE @nr INTEGER;
IF (EXISTS(SELECT * FROM DELETED))
BEGIN
SET @nr = (SELECT COUNT(*) FROM DELETED);
DELETE FROM (
SELECT TOP(@nr - 1)* FROM OferteSpeciale
INNER JOIN DELETED ON OferteSpeciale.codP = Deleted.codP
AND OferteSpeciale.codM = Deleted.codM
AND OferteSpeciale.dela = Deleted.dela)
END