TRIGGER: Copy FROM another table To current table

  • John - True that multiple codes for a part_id did not show up in his data. And you are of course right that code may not be needed in usage of the orders rows later because he can do a join.

    On the other hand, if code may change over time for a part_id, maybe the intention is to capture the current code at the time of the order? While this can be done with effective dates and maintain normalization, it can get mighty messy.

    Grasshopper should clarify.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • dwain.c (2/17/2012)


    On the other hand, if code may change over time for a part_id, maybe the intention is to capture the current code at the time of the order? While this can be done with effective dates and maintain normalization, it can get mighty messy.

    That's a good point, which I hadn't thought of. I'd be surprised if a part code were expected to change, however, and if that were possible, I think I'd prefer to handle it with audit tables. You're right, though - it makes your joins a hell of lot more messy! One mantra I've heard used is this: normalise until it hurts, denormalise until it works.

    John

  • dwain.c (2/17/2012)


    John - You're way over my head with that.

    Maybe grasshopper wants both fields in the join because a PART_ID can have more than one CODE?

    You're absolutely right!

Viewing 3 posts - 16 through 17 (of 17 total)

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