RE: INSTEAD OF DELETE Trigger

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Alejandro Mesa (AlejandroMesa_at_discussions.microsoft.com)
Date: 02/07/05


Date: Mon, 7 Feb 2005 10:45:02 -0800

Try,

CREATE TRIGGER Table1_InsteadOfDeleteTrigger
ON dbo.Table1
INSTEAD OF DELETE
as
DELETE Table1
where exists(SELECT * FROM deleted d where d.pkcol = table1.pkcol)
go

AMB

"mekim" wrote:

> Hi All,
>
> I am writing my first "INSTEAD OF DELETE" trigger and what I need to do is
> delete the actual records that would have been deleted if not for the
> "INSTEAD OF DELETE"
>
> My question is that when I run a trigger I get back a result set in QA (I'm
> not even sure if that matters) and was wondering if there is a better/quicker
> way than I am doing it - it seems too straight forward for me to have gotten
> it right :-)
>
> the trigger code is listed below
>
> Best Regards
> Mekim
>
> CREATE TRIGGER Table1_InsteadOfDeleteTrigger
> ON dbo.Table1
> INSTEAD OF DELETE
> as
> DELETE Table1 SELECT * FROM deleted d
>
>
>



Relevant Pages

  • RE: INSTEAD OF DELETE Trigger
    ... If you do not use the WHERE clause, then all rows will be deleted. ... CREATE TRIGGER Table1_InsteadOfDeleteTrigger ... DELETE Table1 ... >> AMB ...
    (microsoft.public.sqlserver.programming)
  • Re: triggers & Update(Field1) & Field1 = value?
    ... then you write code that assume that your trigger only updates one row. ... SQL Server MVP ... "mekim" wrote in message ...
    (microsoft.public.sqlserver.programming)
  • RE: INSTEAD OF DELETE Trigger
    ... an empty resultset because all rwos were deleted by the io trigger). ... "mekim" wrote: ... > I have a TableQueue that Queues records that when I delete those records ... >> AMB ...
    (microsoft.public.sqlserver.programming)
  • Re: Im not Trigger happy :-)
    ... You should make use of the INSERTED table inside your trigger to identify ... SQL Server MVP ... "mekim" wrote in message ... > -And I wonder what happens when this trigger fires the same trigger each> time the update is called on "RecordVersion" ...
    (microsoft.public.sqlserver.programming)
  • Re: triggers & Update(Field1) & Field1 = value?
    ... > How do u access an inserted/deleted field name? ...
    (microsoft.public.sqlserver.server)