I am seeing some strange behaviour which has occurred more than once for completely unrelated queries.
The COMMIT TRANSACTION statement in a Sql query seems to be being ignored, despite no error occurring, leaving a lock on the table until the process is killed.
Here is one example:
BEGIN TRY
BEGIN TRANSACTION
UPDATE Elements.ProductDeparture
SET DurationDays = 5,
FinishDate = DATEADD(day, 4, DepartureDate)
WHERE DepartureCode LIKE 'PPAF%'
AND ProductID = 2359
COMMIT TRANSACTION
END TRY
BEGIN CATCH
PRINT 'Error: ' + ERROR_MESSAGE()
ROLLBACK
END CATCH
There is no error coming out of the query (if you run it without the transaction it completes fine). The behaviour is reproduceable (i.e. it happens every time the above query is run, not just intermittently).
This has happened twice now, for completely unrelated queries running in transactions.
Here's the weird bit. We have run it in our dev environment, and our test environment, with no issues. Running it in Production causes the process to not complete, holding a lock on the table until the process is killed. They are all SQL Server 2005 environments.
Are there any SQL Server Database settings that could be causing this weird behaviour? So far roughly 5 developers have looked at it, and never seen anything like it.