Home Forums SQL Server 2008 T-SQL (SS2K8) how to avoid two updates hapens same table same time from two different procedures RE: how to avoid two updates hapens same table same time from two different procedures

  • asita (10/12/2016)


    Hello There,

    I have a procedure that is scheduled to run on sql server and some adhoc code that I am executing,

    both is kind of same logic but diferent purpose, here the problem is

    I have a table for get max(id) in the table then drives that id in the code (both places) here my code got updated each other

    how to avoid updating same table/ reading same table when the other table is reading it? please advise

    Thank you in advance

    please help me

    Milan

    Use explicit transactions.

    The table will be locked for any updates until the transaction is committed or rolled back.

    _____________
    Code for TallyGenerator