Original Post
I cannot quite get my mind around SQL Transactions in MSSQL, so I'm just going to ask if this scenario is possible. Two users are posting on a forum: Adam , and Eve. Posting on said thread requires grabbing the LAST_TOPIC_ID, incrementing and saving it, and then of course, using the value in the POST that is to be entered into TABLE_POSTS. Now, Adam and Eve are posting at the EXACT same time. Their posts requests get sent to an MSSQL Stored Procedure that does the above, but encapsulated in a "BEGIN TRANSACTION {sql statements here} COMMIT". Without the TRANSACTION, it is apparent that there is a race-condition here, and that one post could overwrite the other (or worse). But it's not clear to me whether the TRANSACTION is going to prevent the race-condition. The point of transactions appear to be to reverse things when detectable errors occur, but detecting a race-condition is, in itself, subject to a race-condition. So, someone explain this to me... lol