Delete trigger shows nothing in Deleted table

Delete trigger shows nothing in Deleted table

Post by Jim Fo » Sun, 27 May 2001 01:05:42



I have a DELETE trigger defined on a table.  The trigger definitely fires
when I delete from the table.  However, there is nothing in the Deleted
table.  For example, if I put the following code in the trigger:



I've done triggers before without a problem, but this is my first DELETE
trigger, so there's something stupid I'm doing?

Thanks,
Jim

 
 
 

Delete trigger shows nothing in Deleted table

Post by DaveSat » Sun, 27 May 2001 02:37:25


there should only be nothing in the deleted table if no rows were affected
by the DELETE statement that fired the trigger. They will not be any row in
the inserted table, of course, in a delete trigger.
--
HTH,
David Satz
Principal Software Engineer
Hyperion Solutions
->Using SQL Server 7.0 SP3/6.5 SP5a/Cold Fusion 4.5.1 SP2/VSS
(Please reply to group only - emails answered rarely)
-----------------------------------------------------------------


> I have a DELETE trigger defined on a table.  The trigger definitely fires
> when I delete from the table.  However, there is nothing in the Deleted
> table.  For example, if I put the following code in the trigger:



> I've done triggers before without a problem, but this is my first DELETE
> trigger, so there's something stupid I'm doing?

> Thanks,
> Jim


 
 
 

1. instead of delete trigger delete data from table using execute and temporary table for deleted

Hello,

SQL Server 2k has got me confused...below the instead of trigger that
causes all my problems...below the trigger the explanation of my
problem

===============================================================================
create trigger [triggerConcurrenten] on [dbo].[concurrenten]
instead of delete
as
begin
        -- ***** Declare local vars




        begin transaction

        -- ***** Initialize



        select deleted.* into #deleted from deleted

        /*
        Delete data from concurrenten table using the below sql
statement
        works perfectly.
        =============
        delete
        from concurrenten
        where exists(
        select * from #deleted d
        where concurrenten.[id] = d.[id])
        */

        /* Delete using the execute function fails! */







        begin
                raiserror('[triggerConcurrenten]: Error occured!', 16, 1)
                rollback transaction
        end

        commit transaction      
end

===============================================================================

In the trigger I've tried a 'direct' sql statement to delete data from
the concurrenten table. No problem at all...but when I use the execute
function the exact same delete statement fails...what am I doing
wrong?

Thanx in advance for the answer!

Best regards,

Peter

2. Full-Text Search with millions of rows

3. No INSTEAD OF DELETE triggers for tables with ON DELETE CASCADE constraints

4. Visual Basic CGI Script

5. BUG: ADO insert fails if trigger DELETEs nothing.

6. Alter table

7. US-IL-CHICAGO-DATABASE MANAGER-OPTIMA PARTNERS

8. Delete trigger not updating rows using delete from

9. delete trigger or cascade delete, which one??

10. HELP! Creating delete trigger for cascade delete

11. Trigger: delete dependent records when deleting a row

12. ON DELETE CASCADE - does it fire delete trigger?