sql-server 2008 trigger for counting row access.
Posted on 2013-05-19
I have a table like this! (UserData)
itemId, Itemname, ItemUrl,,,,,,,,,
then i have an other table (Accesscounter)
Itemid, NumberOfDOwnload, LatestDownload,,,,,
i need a trigger into sql-server2008 that updates the Accesscounter everytime
a row in Userdata is accessed.
so when itemid x in Userdata is accessed it needs to write the itemid into accessCounter and increment number of downloads and the datetime for latestdownload.
Btw. if the item in AccessCounter already exists it needs to update the row not create a new one!
How would this be done with a trigger? now i deal with it in code but a trigger would be a nicer solution.