General information
Category:
Coding, syntax & commands
>>Hi
>>
>>Looking for a good practice to share a task across 3 machines.
>>
>>The same process is running on 3 separate machine and each process should get the tasks in batches of 20 items from a SQL server table, process each, and mark the record as done when completed.
>>
>>No duplication allowed.
>>
>>What's normally done to achieve this ?
>>
>>TIA
>>John Harriss
>
>There are multiple ways I think. One way would be to use ntile() function to divide the data into 3 partitions. ie:
>
>machineNum = 1
>text to m.lcSQL noshow
>select * from
>(select *,ntile(3) over(order by customerId) as batchNum from customers) allCustomers
>where batchNum = ?m.machineNum
>endtext
>
>(or have a similar partition directly on table itself on SQL server).
>
>Cetin
Thanks Cetin
That looks really good and so easy.
I did a quick test and sure enough the result sets came through so will do some more testing.
It seems that when I run the query and get say batch No1, I cannot get that batch again which is just what's needed. Is that data set permanently partitioned on the the table so it can never be got again ?
If so could it be lifted ?
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only