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

  • Home
  • SEARCH
  • 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 6683841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:52:09+00:00 2026-05-26T04:52:09+00:00

Surprisingly can’t find a match for my question. I have one table that I

  • 0

Surprisingly can’t find a match for my question. I have one table that I need to use a source of data to insert to another and then delete whatever has been inserted. This has to be accomplished in blocking manner, i.e. if the same query/SP is executed at the same time, the same records must not be moved thus creating duplicates.

I have a feeling it’s something relatively simple but I am not sure I totally understand how locking works in SQL. It appears super trivial in C# (just a monitor) but SQL…

As an example, you may consider producer-consumer model, i.e. some sort of a table that serves as a queue, some threads insert into it some consume. Insertion apparently is not a problem, but consumption is what I am wondering about.

UPDATE:
Two good candidate solutions for me:

  • use SELECT FOR UPDATE (need to figure out for how long row locks are
    hold)
  • use a field to mark records before manipulating on them

And still need to figure out that SERIALIZABLE IL thing…

Thank you everyone who took an effort and replied – this community is so great.

  • 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-05-26T04:52:10+00:00Added an answer on May 26, 2026 at 4:52 am

    some suggestions…

    1. make sure your tables have proper keys or unique contraints such that duplicates can not be inserted

    2. I would use a stored procedure to do the bulk move (insert + delete) within a begin/commit transaction. I would also make sure the rows that are selected to move is done so with row level locking. (This could however have a performance impact if these tables have a lot of select requests).

    3. alternatively, you could actually lock on the C# code that invokes this action, blocking to make sure that no to user can enter the invoke the method at the same time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked everywhere and surprisingly can't find a good solution to this! I've
Very simple question (surprisingly I can't find a similar question anywhere): how do I
Suppose we have 3 variables and we need to ASSERT that they can either
I have a question (surprisingly ;) ): How can I return false to a
I find it surprising that Ruby symbols can be typecasted to integers without errors.
I've checked through other questions and surprisingly this question doesn't seem to have been
Is there a function in the Drupal API that I can use to get
Two questions: Can someone point me to unbiased data that compares .NET performance to
I'm trying to find about ALL the possible options that I can set in
I have several reports that are from SSAS 2008, but one of them has

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.