解决方法
最好的方法是使用已有的表格.
@H_403_12@创建两个表 – table-a,table-b
@H_403_12@对于测试,您甚至可以使用相同的信息更新同一列
@H_403_12@所以你不会影响任何真实的数据.
例如@H_403_12@UPDATE table_a set ID = ID,其中ID = 100;
BEGIN TRAN update table_a set ID=ID where ID = 100;
两跑
BEGIN TRAN update table_b set ID=ID where ID =100;
然后,将更新语句复制到对方会话并同时运行.@H_403_12@在一个,
update table_b set ID=ID where ID =100;
成两半
update table_a set ID=ID where ID = 100;
我刚刚尝试了这个并开始使用MS-sql
Msg 1205,Level 13,State 56,Line 1 Transaction (Process ID 23) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.