Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create Trigger
Message
From
07/10/2009 01:09:19
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Environment versions
SQL Server:
SQL Server 2008
Application:
Desktop
Miscellaneous
Thread ID:
01427973
Message ID:
01427981
Views:
60
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform