问题描述
我在SQL Server中有一个数据库表,它有一些未经处理的记录(处理过的flag = 0)。我有一个批处理程序,它将从2台独立的机器上执行,以处理这些记录。我的要求是我需要在第一台机器上使用批量运行处理一半
的记录,而在第二台机器上使用批处理则需要处理后半部分。我还想要,如果一个记录已经被一个批处理选中,那么如果它在表上运行一个select语句语句,那么对于所有未处理的记录,它应该不会被另一个记录查找
。处理完记录后,其处理过的标记可以标记为"1"
实现此目的的最佳方法是什么?我不想在选择时使用ROWLOCKS,因为它会妨碍从UI访问所有此类记录。
谢谢
Vedanshu
Hi,
I have a database table in SQL server which has some un-processed records (processed flag = 0). I have a batch program which is going to be executed from 2 separate machines for processing these records. My requirement is that I need to process half of records using batch running on first machine and second half using batch on the second machine. I also want that if a record has been picked up by one batch, it should not be picked up by the other if it runs a select statement statement on the table looking for all unprocessed records. After a record has been processed, its processed flag can be marked say '1'
What is the best possible way to accomplish this? I do not want to use ROWLOCKS while selecting as it would hamper the access of all such records from the UI.
Thanks
Vedanshu
这篇关于多进程数据访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!