declare @spid int
    declare @tableName varchar(100)
    declare @sql varchar(1000)
    Declare CurDispatchPurch
    Cursor local Scroll for
    select
    request_session_id spid,
    OBJECT_NAME(resource_associated_entity_id) tableName
    from
    sys.dm_tran_locks
    where
    resource_type=’OBJECT’ —and OBJECT_NAME(resource_associated_entity_id) <> null
    open CurDispatchPurch

    fetch next from CurDispatchPurch into @spid, @tableName
    while (@@fetch_status = 0)
    begin
    set @sql=’kill ‘+cast(@spid as varchar)
    exec(@sql)
    fetch next from CurDispatchPurch into @spid, @tableName
    end