Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Hadware
Starting Member
6 Posts |
Posted - 2006-01-06 : 17:43:06
|
| 1. How do I perform consecutive updates on a table, then loop to the beginning and continue to update?2.If I have a table likeCreate Table table1(Col1 bit, Col2 int, Col3 int, col5 datetime, col6 int primary identity)3. Data:Insert INTO table1(Col1, Col2, Col3, col5, col6) --I tried, but can't figure out the instructions at this level.http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxThere are 4 entries in the table and col6 increments by 1 and starts at 14. Update table1 set col1 = '1' where col6 = @declaredvariablethis update must happen 9 times consecutively and then loop to the beginning ...1, 2, 3, 4, 1, 2, 3, 4, 1even if one of the entries gets deleted: 1,2,4,1,2,4,1,2,4I can get the top 9 * but it doesn't loop back around.Thank-you,Eric |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-06 : 19:21:08
|
| It is not very clear what you are trying to achieve here. I see you have Brett's link there. Can you post as suggested in the link ? Post some sample data and the desire result-----------------[KH] |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2006-01-06 : 20:51:52
|
| please post some code showing how you are trying to accomplish this. -ec |
 |
|
|
Hadware
Starting Member
6 Posts |
Posted - 2006-01-06 : 21:24:02
|
| I actually have no code because I do not know how to accomplish this.I just need to perform an update on 9 consecutive rows in a table. But if the table contains only 4 rows then the update has to start back from the beginning until the total amount of updates executed is 9.ps: I just use 9 as an example, it could be another integer.The main idea is to be able to start back from the beginning of the table again. |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2006-01-06 : 23:02:43
|
| will your update ever fall out of the loop and be complete? or do you want to continually update the table for an infinite amount of time?-ec |
 |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2006-01-07 : 00:06:45
|
| You will need to define what you mean by "consecutive". Relational data has no inherent order, so what column are you sorting by?Also, does your update always start at the "first" record? And is there an upper bound on the number of records updated in a transaction? |
 |
|
|
|
|
|
|
|