Home Forums SQL Server 7,2000 General do it in database layer or application layer RE: do it in database layer or application layer

  • This may be too complicated in your app but I once had to insert to many tables from an app and roll back all if one went wrong.

    What I ended up doing was creating temporary duplicates of the tables I was inserting to, writing to these instead, if this was successful, running a single procedure that moved all the data into the real tables.

    Because the temp tables were exact matches of the real ones any errors would occur when putting data in them and not at the copying across step, then I could just delete the temp tables when a failure did occur.

    The final copying across step I further wrapped in a transaction just in case it ever failed, which it never did as it was a simple 1 to 1 copy of rows from identical tables.

     


    "Don`t try to engage my enthusiasm, I don`t have one."

    (Marvin)