Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi All,

I am facing deadlock problem on Dispatching.PackageTrace table when below Embedded SQL is invoked through C# programming language in MS SQL Server 2014.


Below is the table design in Database:

CREATE TABLE [Dispatching].[PackageTrace](
[PackageID] [uniqueidentifier] ROWGUIDCOL NOT NULL,
[PartitionID] [numeric](26, 0) NULL,
[Conduit] [nvarchar](255) NOT NULL,
PRIMARY KEY CLUSTERED
(
[PackageID] ASC
)


IF EXISTS(SELECT * FROM Dispatching.PackageTrace WHERE PackageID = 'klaslndsskok230m')
BEGIN
UPDATE [Dispatching].[PackageTrace] SET [Conduit] = @Conduit
WHERE [PackageID] = 'klaslndsskok230m'
END
ELSE
BEGIN
INSERT INTO [Dispatching].[PackageTrace] ([PackageID] ,[PartitionID] ,[Conduit] )
VALUES (@PackageID, @PartitionID, @Conduit)
END


Suggestions really appreciated to over come from deadlock problem.

Thank you in advance.
--Raj
Posted
Comments
Sinisa Hajnal 6-Nov-14 5:55am    
This seems legal, it's probably your code that locks the table.
ZurdoDev 6-Nov-14 7:34am    
Use the ACtivity Monitor in SQL to see what is locking it.

1 solution

Try to write your select query with a nolock statement. It should improve your situation a lot. Otherwise this part will block the entire table when running causing deadlocks.

SELECT * FROM Dispatching.PackageTrace (NOLOCK) WHERE PackageID = 'klaslndsskok230m'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900