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 659259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:01:28+00:00 2026-05-13T23:01:28+00:00

(I realize that my title is poor. If after reading the question you have

  • 0

(I realize that my title is poor. If after reading the question you have an improvement in mind, please either edit it or tell me and I’ll change it.)

I have the relatively common scenario of a job table which has 1 row for some thing that needs to be done. For example, it could be a list of emails to be sent. The table looks something like this:

ID    Completed    TimeCompleted   anything else...
----  ---------    -------------   ----------------
1     No                           blabla
2     No                           blabla
3     Yes          01:04:22
...

I’m looking either for a standard practice/pattern (or code – C#/SQL Server preferred) for periodically “scanning” (I use the term “scanning” very loosely) this table, finding the not-completed items, doing the action and then marking them completed once done successfully.

In addition to the basic process for accomplishing the above, I’m considering the following requirements:

  • I’d like some means of “scaling linearly”, e.g. running multiple “worker processes” simultaneously or threading or whatever. (Just a specific technical thought – I’m assuming that as a result of this requirement, I need some method of marking an item as “in progress” to avoid attempting the action multiple times.)
  • Each item in the table should only be executed once.

Some other thoughts:

  • I’m not particularly concerned with the implementation being done in the database (e.g. in T-SQL or PL/SQL code) vs. some external program code (e.g. a standalone executable or some action triggered by a web page) which is executed against the database
  • Whether the “doing the action” part is done synchronously or asynchronously is not something I’m considering as part of this question.
  • 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-13T23:01:28+00:00Added an answer on May 13, 2026 at 11:01 pm

    If you’re willing to consider non-database technologies, the best (though not the only) solution is message queuing (often in conjunction with a database that contains each job’s details). Message queues provide a lot of functionality, but the basic workflow is simple:

    1) One process puts a ‘job message’ (perhaps just an id) on a queue.

    2) Another process keeps an eye on the queue. It polls the queue for work, and pulls jobs it finds off the queue, one at a time, in the order they were received. Items you’ve pulled off the queue are effectively marked as ‘in progress’ – they are no longer available to other processes.

    3) For critical workflows, you can perform a transactional read – in the event of a system failure, the transaction rolls back and the message is still on the queue. If there’s some other kind of exception (like a timeout during a database read), you might just forward the message to a special error queue.

    The simplest way to scale this is to have your reader process dispatch multiple threads to handle jobs it pulls off the queue. Alternately, you can scale out using multiple reader processes, which may be on separate servers.

    .NET support includes Microsoft Message Queue, and either Windows Communication Foundation or the classes in the System.Messaging namespace. It requires some setup and configuration (you have to create the queues and configure permissions), but it’s worth it.

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

Sidebar

Related Questions

I realize that this question has been asked 100times but none that I have
sorry, I realize my title is confusing. Please let me explain. I have a
I realize that a SO user has formerly asked this question but it was
I realize that the answer to this question is likely quite obvious (if somewhat
Hopefully that title makes sense... Let's say I have an employee table: ID |
I want a program that does what I said in the title. I realize
I am creating a neural network using MATLAB (version specified in title). After reading
Feel free to edit the title if you know how to formulate the question
I realize this question is very likely to have been asked before, but I've
I realize that the title is a long one, but allow me to explain.

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.