Transactions and Stored Procedures

Because SQL code in stored procedures runs locally on the server, it is recommended that entire transactions be completely encapsulated within stored procedures to speed transaction processing. This way, the entire transaction executes within a single stored procedure call from the client application, rather than being executed across multiple requests. The less network traffic that occurs between the client application and SQL Server during transactions, the faster they can finish.

Another advantage of using stored procedures for transactions is that doing so helps you avoid the occurrence of partial transactions—that is, transactions that are started but not fully committed. Using stored procedures this way ...

Get Microsoft® SQL Server 2012 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.