Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

sql query

Options
  • 22-11-2007 1:43pm
    #1
    Closed Accounts Posts: 346 ✭✭


    is there anyway i can track on what way data is written to tables in using sql server
    .ie. how do i know it wrote to table 1 before it wrote to table 3

    am new to sql sorry for the stupid question
    thanks


Comments

  • Closed Accounts Posts: 2,046 ✭✭✭democrates


    coolio_64 wrote: »
    is there anyway i can track on what way data is written to tables in using sql server
    .ie. how do i know it wrote to table 1 before it wrote to table 3

    am new to sql sorry for the stupid question
    thanks
    Sounds like you need a transaction so that for example you don't create a debit without a matching credit. If the later statement fails the whole transaction rolls back.

    If it's the auto-generated id from the first table you need before inserting in the second, eg you need the auto-generated id for a new order before inserting order line items to order_detail, I seem to recall a stored procedure was needed to return that id, but that workaround might no longer be required with recent versions of sql server.


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    coolio_64 wrote: »
    is there anyway i can track on what way data is written to tables in using sql server

    If you're talking about MS SQL Server, then you probably want to have a look at the Profiler.
    .ie. how do i know it wrote to table 1 before it wrote to table 3

    am new to sql sorry for the stupid question
    Its not a stupid question, but its hard to know what the right answer is to suggest to you without knowing why you want to do this.

    Why do you want to do this?


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    bonkey wrote: »
    its hard to know what the right answer is to suggest to you without knowing why you want to do this.

    Why do you want to do this?

    Exactly, there are probably several different methods depending on that.

    Do you need to ensure that table 1 is written to first, or do you just need to know if it's written to first - in the latter case, could a simple time stamp column work? I presume that a trigger called upon the insert to table 1 could then write to table 2.


Advertisement