Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9142207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:44:49+00:00 2026-06-17T09:44:49+00:00

I am getting Dead Lock exceptions in my C# code when I call my

  • 0

I am getting Dead Lock exceptions in my C# code when I call my stored procedure to update/insert into my Configuration table.

The SP_Update_Configuration stored procedure will either insert a new record or update an existing record.

The Triggers are setup to keep a history of previous records in a history table. If the Configuration table has an update or an insert, then it should add that record to the Configuration_History table.

I believe the triggers are causing the deadlock? I did not have any problems previous to adding triggers…. Any Ideas?

I am using SQL Server 2012 Express.

Here is an example of my SQL:

CREATE PROCEDURE SP_Update_Configuration
( 
--Input variables
) 
AS
BEGIN TRANSACTION
DECLARE @RetCode INT
DECLARE @RowCnt INT
    --Standard Update Logic
SELECT @RowCnt = @@ROWCOUNT

IF @@ERROR <> 0
   BEGIN
    ROLLBACK TRAN
    SET @RetCode = 5
    RETURN @RetCode
   END

IF @RowCnt = 0
    BEGIN
        --Standard Insert Logic
    END

IF @@ERROR <> 0
   BEGIN
    ROLLBACK TRAN
    SET @RetCode = 5
    RETURN @RetCode
   END

COMMIT TRANSACTION
GO

create trigger dbo.Configuration_Log_Insert 
on dbo.Configuration
  for insert
as
  set nocount on
  insert into Configuration_History
    select *
      from Configuration
go

exec sp_settriggerorder @triggername = 'Configuration_Log_Insert', @order = 'last', @stmttype = 'insert'  

create trigger dbo.Configuration_Log_Update 
on dbo.Configuration
  for update
as
  set nocount on
  insert into Configuration_History
    select *
      from Configuration
go

exec sp_settriggerorder @triggername = 'Configuration_Log_Update', @order = 'last', @stmttype = 'update'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:44:50+00:00Added an answer on June 17, 2026 at 9:44 am
    SELECT @RowCnt = @@ROWCOUNT
    
    IF @@ERROR <> 0
    

    here you have trouble, because @@ERROR is error code of

    SELECT @RowCnt = @@ROWCOUNT
    

    You can do this as:

    SELECT @RowCnt = @@ROWCOUNT, @error = @@ERROR
    
    IF @error <> 0
    

    In triggers you have

      insert into Configuration_History
        select *
          from Configuration
    

    but is must be

      insert into Configuration_History
        select *
          from inserted 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting a dead code warning in a for loop at i++ . Why
I am using Sqlite on a production server but getting into deadlock scenarios. I
I'm developing tool, which takes Java code and generate code for getting estimations for
While sending ARRAY to the stord proc we are getting java level dead locks.
This is the first time I see this code myself where we are getting
I've got a stored procedure that does the following (Simplified): SET TRANSACTION ISOLATION LEVEL
I am getting a database table value in wxListCtrl, (data can be large so
I've recently got into getting data from servers . For example, from a CoD
I’m running into a deadlock problem when trying to lock some records so that
I am getting a deadlock on concurrent users for insertion on my table. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.