Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

DeadLocks issue

$
0
0

Hi All,

We are having DeadLock issue on our application and we put a job on SQL and monitors on which SP the deadlock is happening and once the deadlock happens it sends the Store Procedure where it happening. Below is the Code of the SP. Please some one take a look and let us know is anything wrong with the code.

CREATE procedure [dbo].[CNR_UPDATE_INSERT_PENDING_QUERY_BY_ID_NG]
    @cnr_user_id int,
    @CNR_Query_ID varchar(100) = null
as
    declare @errormsg varchar(250)
BEGIN
    Declare @WorkQueryList varchar(100);
    Set @WorkQueryList = REPLACE(@CNR_Query_ID, ' ', '')
    Set @WorkQueryList = ';' +  REPLACE(@WorkQueryList,',', ';') + ';'

    
    update    CNR_Query
    set        submitted=1
    where    CNR_user_id= CAST(@cnr_user_id AS VARCHAR)
    and        patindex('%;' + cast(CNR_Query_ID as varchar) + ';%', @WorkQueryList) <> 0
    
    
    Update CNR_Query_Log
    Set Submitted = 1
    where    CNR_user_id= CAST(@cnr_user_id AS VARCHAR)
    and        patindex('%;' + cast(CNR_Query_ID as varchar) + ';%', @WorkQueryList) <> 0
        
    
    Delete From CNR_Query
    Where patindex('%;' + cast(CNR_Query_ID as varchar) + ';%', @WorkQueryList) <> 0
    And    Pending_Query.WS_User_ID is not null             

if @@ERROR <> 0
    begin
        select @errormsg = description
        from master.dbo.sysmessages
        where error = @@ERROR
        insert into CNR_error_log
        values (getdate(),@@PROCID,@@ERROR,@errormsg)
    END
return
END


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>