[Solved] Simulate a dead lock on SQL server using single client and single session


This is currently possible.

The following code deadlocks itself

BEGIN TRAN
CREATE TYPE dbo.OptionIDs AS TABLE( OptionID INT PRIMARY KEY )
EXEC ('DECLARE @OptionIDs dbo.OptionIDs;')
ROLLBACK 

This is a long standing issue due to the use of internal system transactions when creating the instance of the TVP that can’t access the lock taken by the user transaction.

At some point it may be fixed though

2

solved Simulate a dead lock on SQL server using single client and single session