sql查看表的锁并解锁
select request_session_id as id,OBJECT_NAME(resource_associated_entity_id) as tablename from sys.dm_tran_lockswhere resource_type=’OBJECT’
kill id 例如:kill 58
------------------------
鎖測試:
begin tran
select * from brand with (TABLOCKX)
raiserror ('dd',16,1)
commit tran
------------------------
raiserror不會自動回滾,要配合try,,catch使用。[11,19],则跳到catch
begin tran
update brand set des1='222' where brand='00'
select * from brand with (TABLOCKX)
raiserror ('dd',16,1)
commit tran
select * from brand
update brand set des1='111' where brand='00'