dilettante
MIS
Can this be done? I seem to have the syntax balled up.
[tt]UPDATE Parent
SET ChildCount = (SELECT Count(1) WHERE Child.ParentID = Parent.ParentID);[/tt]
Yes, the Parent.ChildCount isn't normalized. That's intentional. There is a one-to-many relationship linking the two tables on ParentID though.
The error I get is the familiar one about needing an updateable query. I assume aggregate queries are never updateable.
Is there anything better than the hack I'm using to get around this right now? I'm looping over the Parent table's rows, and for each one doing another query to retrieve the Count(1) of matching Child table rows, updating via ADO.
[tt]UPDATE Parent
SET ChildCount = (SELECT Count(1) WHERE Child.ParentID = Parent.ParentID);[/tt]
Yes, the Parent.ChildCount isn't normalized. That's intentional. There is a one-to-many relationship linking the two tables on ParentID though.
The error I get is the familiar one about needing an updateable query. I assume aggregate queries are never updateable.
Is there anything better than the hack I'm using to get around this right now? I'm looping over the Parent table's rows, and for each one doing another query to retrieve the Count(1) of matching Child table rows, updating via ADO.