Forcing multiple statements to execute as a single group

  • Is there a way to force one or more SQL statements to execute together, even if other connections are trying to process transactions simultaneously? Basically I'm looking for a guarantee similar to sychronized methods in Java, but at the database level.

    Thanks,

    Kevin

  • Hi

    I'm not sure if I got you. What about "BEGIN TRANSACTION" "COMMIT TRANSACTION"?

    Greets

    Flo

  • Kevin,

    To answer your question literally, the closest analogue to a synchronized method call would be a transaction (as Florian described) running at the SERIALIZABLE isolation level.

    I think it is really important that you share your reasons for investigating this, so we can be sure of giving you appropriate advice. Developers often want to directly translate programming concepts to SQL Server (with good reason!) but there are almost always reasons not to do that, and built-in SQL Server features which make it unnecessary anyway.

    For example, SQL Server provides a number of methods to implement queuing, and even more to ensure that separate transactions (threads?) do not encounter synchonization-type problems.

    So, please share some more detail...thanks!

    Paul

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply