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 |
scelamko
Constraint Violating Yak Guru
309 Posts |
Posted - 2007-02-23 : 11:11:53
|
guysI have 2 columns id and iid, I am trying to write tsql which will populate in the follow wayID IID1 42 43 44 55 56 57 68 69 6basically for every 3 rows starting from 1 IID should be duplicated and for next 3 rows it should be duplicated by increment of 1update testset iid = 4DECLARE @CURRENTID INT, @CURRENTIID INTSELECT @CURRENTID = [ID], @CURRENTIID = [IID]FROM [test]WHILE @CURRENTID <= MAX([id])BEGINIF (@CURRENTID)/3 = 0 THEN @CURRENTIID = @CURRENTIID+1ELSE @CURRENTIIDENDany suggestions/inputs would helpThanks |
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
|
|
|