Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How do Create Trigger After Update

$
0
0

there my dear,
I'm experiencing some difficulties when creating a trigger to update when a change occurs in a particular column of a table, with an update occurs in other columns.

I own a system to run a command does the following query: update character set = resets resets +1
Soon I need a trigger that occurs when this query above also run: update character set resetsweek resetswek = +1, resetsmonth resetsmont = +1, +1 resetsday = resetsday

I did this trigger:

CREATE TRIGGER [add_resetrank]
ON dbo.[Character]
after update
as
IF UPDATE(resets)
begin
Update [Character] set [Character].reset_week=reset_week+1, reset_month=reset_month+1, reset_day = reset_day+1
Where [Character].accountid=(SELECT accountid FROM Inserted)
and [Character].name=(SELECT name FROM Inserted)
end

The problem is that when change occurs in a accountid, he's running the update on all other accountid (which would be the personal account of each user) and NAME are also linked each to their particular accountid

If you can give me a light on this I am very grateful, thank you now.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>