0

We have several instances of our application running at the same time at various places.

And all instances execute an insert or update query on a single table Orders.

Orders
---------------------------------------

OrderID OrderDate OrderTime OrderAmount

The question is, if all instances of my application insert or update records at the same time, what might happen?

How does MSSQL database handle this scenario?

I googled out and found ROWLOCK, XLOCK, READPAST as a solution on concurrent access to MSSQL database but could not find an exact answer for the above scenario!

Any pointers is much appreciated.

2 Answers2

1

Each INSERT or UPDATE will run in an (implicit) transaction such that the statements will be queued. This should normally not be a problem.

If the INSERT or UPDATE statements are part of a batch with other statements which need to be run uninterrupted (such as first reading from a table, then updating the table based on the result), you should consider enclosing these statements in an explicit BEGIN TRANSACTION / COMMIT TRANSACTION clause.

Daniel B
  • 797
  • 4
  • 13
0

You should read up on Transactions. This will enable you to avoid any data corruption which will occur from your current setup.

Chris L
  • 2,262
  • 1
  • 18
  • 33