January 9, 2014 at 1:13 am
I have a table with records as follows: Its just a sample table for understanding the scenario.
Create table resetcount
(
userid int,
totalhighprtjobs int,
[date] datetime
)
insert into resetcount Values (147,0,GETDATE())
insert into resetcount Values (169,1,GETDATE())
insert into resetcount Values (176,0,GETDATE())
insert into resetcount Values (187,1,GETDATE())
insert into resetcount Values (188,1,GETDATE())
Everytime when i assign a job to a userid the totalhighprtjobs gets increased by 1.it will assign to all the users randomly and equally. Suppose if all the count of totalhighprtjpbs becomes 1 then i want to reset all those to 0.if suppose today there are 3 jobs assigned to useids 169,187,188.tomorrow while assigning jobs since the count of highprtjobs of userid 147 and 176 are 0 first these two will be assigned a job.After assigning to these two the count ot totalhighprtjobs wil be 1 for all,then i want to reset the count to 0 for all after assigning to those two.
Can you guide me in this ..
January 9, 2014 at 3:06 am
I'm not sure that I understand you correctly, but if I do, then you just need to check if you have the value 0 in totalhighprtjobs column. Something like that:
IF NOT EXISTS (SELECT * FROM resetcount WHERE totalhighprtjobs = 0)
Update resetcount set totalhihprtjobs = 0
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply