????????????????????
????????????
????SELECT*FROMtableWITH(HOLDLOCK)
???????:????????????????????
????????????
????SELECT*FROMtableWITH(HOLDLOCK)
????????????????????????????????
????????????
????SELECT*FROMtableWITH(TABLOCKX)
??????????????????????o????
????SELECT?????“???????”????????
????SQLServer??????????????????????????????????????????????????????????SQLServer???????????????select????????“???????”?????????Ч?????????????SELECT????е????“???????”??????????????
?????????????
????????????

????selectrequest_session_idspid??OBJECT_NAME(resource_associated_entity_id)tableName
????fromsys.dm_tran_lockswhereresource_type='OBJECT'
????spid???????
????tableName????????
????[@more@]
??????????
????1.??????????Table
????????????
????CREATETABLE#HarveyLock
????(
????SPIDINT??
????DBIDINT??
????OBJIDINT??
????INDIDINT??
????TYPEVARCHAR(100)??
????RESOURCEVARCHAR(100)??
????MODEVARCHAR(100)??
????STATUSVARCHAR(100)
????)
????2.??Lock????????Table
????INSERTINTO#HarveyLockEXECSP_LOCK
????3.??Table????????????????LOCK
????SELECT*FROM#HarveyLock
????4.KILL???LOCK
????KILL@SPID
??????
????????????
????declare@spidint
????Set@spid=57--???????
????declare@sqlvarchar(1000)
????set@sql='kill'+cast(@spidasvarchar)
????exec(@sql)