Welcome! Please take a few seconds to create your free account to post threads, make some friends, remove a few ads while surfing and much more. ClutchFans has been bringing fans together to talk Houston Sports since 1996. Join us!
There was a flaw in the original update trigger. It didn't take into account recalculating the count of the groupid that got replaced.
The same way you created the members table
To think, I came to the Hangout to get away from work :D
Try this. It ain't pretty, but this should work for you. CREATE TRIGGER UpdateMemberCount ON [dbo].[members] FOR Insert, Delete, Update AS...
No, that was only the delete trigger. Also, the if not update groupid line isn't in the right trigger, that is only for the update trigger....
You can insert/update/delete from the members table like normal. A trigger won't affect that, only after the action took place (for an after...
Oh also, about the update, you would only want to recalc NumMems if the groupid was changed. You can check if the groupid has changed using the...
My bad, i forgot about delete, as that would affect the count as well. Since the update will change the groupid, then you'll also have to...
Since it's doing a count, you'll only have to recalc the NumMems after an insert occured in the members table. An update shouldn't affect the...
Wal-Mart = Evil RIAA = Evil Wal-Mart + RIAA = lower cd prices. (hopefully) Wow, two wrongs do make a right!
I know a little about triggers... What is that that you want to do, update the memebers.groupid column when an update occurs?
Glad it worked for you. If this messings up production data.. um you don't know me.
actually I meant groups.gid b/c groups.gid = members.groupid right? Update groups set NumMems = (select count(*) from members where...
Yeah, this should work. Ignore my last post, it is incorrect syntax Update groups set NumMems = (select count(*) from members where...
I donno if I'm understanding you correctly, this work? update groups g1 set g1.NumMems = (select count(*) from members as m where m.groupid...
1. Sucker A person that has been tricked into something. A gullible person. http://www.urbandictionary.com/define.php?term=Sucker&r=f
This site is great, it has tons of words and acronyms! Every word you ever needed to be cool and navigate the interwebbie thing. pwned IDP...
oh duh, it says right there on the front page.
Apparently Ms. "Sped" isn't writing for the blog anymore and they are looking for another writer. Wonder what happenend, if she was just tired of...
Thank you very much Dan for all your work on this outstanding thread!