Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best Way To Do This
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
01520112
Message ID:
01520141
Views:
57
>>I have a table of voter info called Farmers with 92K rows in it. I also have a table of voters called tblCamp_CT with 9 million rows. I added a column to tblCamp_CT called 'IsFarmer' TINYINT.
>>
>>I now need to go through the Farmers table and for every row find the person in the tblCamp_CT using First Name, Last Name, Middle Name, and maybe some other info. If that person exists in the tblCamp_CT table, then set IsFarmer to 1.
>>
>>Wat's the best way to do something like this?
>
>
>WHILE (2 > 1)
>  BEGIN
>    BEGIN TRANSACTION
>    UPDATE TOP ( 10000 ) tblCamp_CT SET isFarmer = 1
>    FROM tblCamp
>    INNER JOIN Farmers ON ....
>    WHERE  tblCamp.isFarmer = 0
>    
>    IF @@ROWCOUNT = 0
>      BEGIN
>        COMMIT TRANSACTION
>        BREAK
>      END
>    COMMIT TRANSACTION
>  END -- WHILE
>
Boris,

It's a good idea to use a loop, but we need a different field to use, say, Processed. Otherwise you will be running an infinite loop, since not all people are farmers.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform