SQL Trigger

  • I have 2 tables.

    tblParts

    columns: PartID, PartNum, PartPrice

    tblPricing

    Columns: PricingID, PartID, PartPrice1

    When tblParts.PartPrice is updated or inserted i want to insert the new price and the PartID into tblpricing accordingly.

    What would be the best way to accomplish this?

  • To have someone guide you to the proper answer, it would help if you posted your question in a meaningful format Please follow the link in my signature and repost the question.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • You have a few options. One is a trigger, another is the update proc, another is the front-end code.

    The easiest and most consistent is probably a trigger, but that does have a few drawbacks (mainly that triggers are pretty much invisible if you forget them, and can be a pain later in that case).

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • I just don't see a need for the pricing table... all of the required information is in the parts table. There is no need to have duplicate information in the database.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Thank you for your responses!

    I am using this data for 2 things.

    1 is historical tracking of the price and also data auditing.

    You have answered my questions Thanks!

Viewing 5 posts - 1 through 4 (of 4 total)

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