0

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
  )    GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [Dispatching].[PackageTrace] ADD  DEFAULT (getdate()) FOR [DateCreated]
GO

below Embedded SQL is invoked through C# programming language in MS SQL Server 2014:

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 overcome from deadlock.

Thank you in advance. --Raj

Raj
  • 313
  • 2
  • 9
  • Where or on what is the deadlock? – rene Nov 06 '14 at 10:29
  • You need a deadlock trace graph to figure out why the deadlock is happening. See [Detecting and Ending Deadlocks](http://technet.microsoft.com/en-us/library/ms178104%28v=sql.105%29.aspx) – Justin Nov 06 '14 at 10:46
  • Thank you for the comments Rene, Justin. I will check about deadlock, I think deadlock is on table packageTree. I will see the trace graph also and will let you know if still I face problem. – Raj Nov 06 '14 at 12:39

0 Answers0