Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Administration - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 6525

How to understand this deadlock

$
0
0
Hi please find attached.Procedure:[code="sql"]CREATE PROCEDURE [dbo].[RSDocument_Store] -- Add the parameters for the stored procedure here @ID int = 0, @DocumentType int, @EntityID int, @VersionNumber int=1, @DocumentGUID uniqueidentifier=null, @BorrowerDocumentGUID uniqueidentifier=null, @LenderDocumentGUID uniqueidentifier=null, @BinaryLength bigint, @BinaryData varbinary(max)ASBEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; if @ID=0 BEGIN DELETE [dbo].[RSDocuments] WHERE DocumentType=@DocumentType AND EntityID=@EntityID AND DocumentType <> 5 AND DocumentType <> 130 AND DocumentType <> 170 INSERT [dbo].[RSDocuments](DocumentType,EntityID,VersionNumber,DocumentGUID,BorrowerDocumentGUID, LenderDocumentGUID,BinaryLength,BinaryData) VALUES (@DocumentType,@EntityID,@VersionNumber,@DocumentGUID,@BorrowerDocumentGUID, @LenderDocumentGUID,@BinaryLength,@BinaryData) SELECT @ID = @@IDENTITY END ELSE BEGIN UPDATE [dbo].[RSDocuments] SET DocumentType=@DocumentType, EntityID=@EntityID, VersionNumber=@VersionNumber, DocumentGUID=@DocumentGUID, BorrowerDocumentGUID=@BorrowerDocumentGUID, LenderDocumentGUID=@LenderDocumentGUID, BinaryLength=@BinaryLength, BinaryData=@BinaryData WHERE ID=@ID END SELECT * FROM [dbo].[RSDocuments] WHERE ID=@IDEND[/code]

Viewing all articles
Browse latest Browse all 6525

Trending Articles