Update parent value from child values

  • Without cursors, can I concatenate top 30 child values into one parent value within the parent

    Update parent

    Set Parent.value1 =

    ( select top 30 @STR = @STR + child.value

    from child

    where child.key = parent.key

    and child.value <> 'blah'

    order by child.priority

    )

    When thru, ALL parent.value1 fields should contain the concatenated child values.

  • You need to create function from your inner query and use it like this:

    SELECT ..., dbo.ConcatCodes(key, 30)

    FROM ParentTable

    _____________
    Code for TallyGenerator

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply