Is it possible to have SQL Server auto rollback your transactions after a certain amount of time to avoid the blocking/locking that is caused? I have been guilty of this in the past and I hear it from many others that it is a common mistake.
For example: I always use a block such as this When doing deletes/updates.
BEGIN TRAN --SQL Code Here ROLLBACK TRAN COMMIT TRAN
This allows me to see how many rows are affected or perform a select on the data and then I can comment out the
ROLLBACK which will automatically
However, there is a possibility of the of not having the
COMMIT highlighted/selected which causes the transaction to hang. What I am looking for is a setting such as:
BEGIN TRAN 15 Seconds --SQL Code Here ROLLBACK TRAN COMMIT TRAN
This will only keep the transaction open a max of 15 seconds.
If this is not possible, does anyone have a better workflow for this?