Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Create Trigger
Message
De
07/10/2009 01:09:19
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Desktop
Divers
Thread ID:
01427973
Message ID:
01427981
Vues:
59
not working correctly

let say TableA have this row

id name followid
--- --------- -----------
a a e
b b e
c c e
d d e
e e null

when changing e to f

id name followid
--- --------- -----------
a a f
b b f
c c f
d d f
f e null




>>Can someone help me with this :-
>>
>>Table A
>>-----------
>>id
>>name
>>followid (follow another record id)
>>
>>
>>i need to create a trigger on Table A so whenever the id change,
>>a trigger will fire on Table A to update all the followid that have the same value as the inserted.id
>>
>>
>>thanks in advance
>
>You need to be careful to not fall into infinite loop
>
>create trigger tr_TableA_Update ON TableA for UPDATE
>AS
>  BEGIN
>         update TableA set FollowID = Inserted.ID from TableA 
>inner join Inserted on ID = Inserted.ID inner join Deleted on TableA.FollowID = Deleted.ID
> END
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform