Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Self Join Referential Integrity
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01523616
Message ID:
01523645
Vues:
18
>>>Should this do it:
>>>
>>>
CREATE TRIGGER PersonsDeleteDependents 
>>>   ON  Persons
>>>   FOR DELETE
>>>AS 
>>>BEGIN
>>>	-- SET NOCOUNT ON added to prevent extra result sets from
>>>	-- interfering with SELECT statements.
>>>	SET NOCOUNT ON;
>>>
>>>    -- Insert statements for trigger here
>>>    delete Persons
>>>    from Persons
>>>    inner join deleted on deleted.personid = persons.parentid
>>>
>>>END
>>>
>>>?
>>
>>The trigger looks OK, but did you have recursive triggers enabled?
>>How many levels of parenting you may have?
>>What if you delete a child that has siblings?
>
>I am thinking we want to disable recursive triggers and implement the whole loop logic in one trigger.


It depends how many level you have :-(
What if you have this:
Parent
   Child1
   Child2
       Grand Child1  
       Grand Child2
             Grand Grand Child1
and you delete Parent?
In this trigger you will delete Child1 and Child2 but not all Grands ;o)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform