Deleting Lost Transactions in MS SQL Server (Part 2)

In the first part, we presented the general algorithm for deleting open transactions that are not completed from a SQL Server database and considered the process of creating a table to record incomplete transactions. Now, let’s look at the process of creating a CRUD stored procedure to find and delete active transactions in SQL Server.

To perform the remaining steps of the algorithm, we’ll implement the stored procedure [srv]. [AutoKillSessionTranBegin].

Deleting Lost Transactions in MS SQL Server

Introduction

Quite often, transactions in MS SQL Server are lost by those who launched them. It is not infrequent that one runs a script in SSMS, which starts an explicit transaction with the BEGIN TRANSACTION statement, but then an error occurs and COMMIT TRANSACTION or ROLLBACK TRANSACTION fails while the transaction initiator has left this query for some time. Transactions left forgotten for long periods of time can prevent users from accessing the locked resources (tables, server resources (RAM, CPU, I / O system).

In this article, we will consider how to delete lost transactions using SQL Complete.

Synchronizing Data in SQL Server

We looked at why exactly change synchronization is important and how to synchronize SQL Server databases by using Schema Compare Tool in my previous article Synchronizing MS SQL Server Databases. Feel free to check it out before reading further if you want to know more on the topic.

In this article, I’ll give an example of how to synchronize SQL Server data changes between servers with the help ofdbForgeData Compare for SQL Server.