Hi - The cursor below is suppose to copy data from a perm. table into a temp. table then make changes to the data and copy it back into the perm. table
Once in this temp table, I am trying to get the cursor to fill all gaps of column points as this column must be consecutive numbers.
Currently the table is something like this:
points type xxx
1 type7 123
2 type1 321
3 type3 654
5 type1 456
7 type9 987
15 type2 147
16 type2 789
17 type2 369
...
.....
Here is the code:
This code is obviously not compiling..
much grateful for any light you can shed for the newbie
[I have also tried doing this via sql update commands (from another thread) but this did not work so decided to go for the Cursor option.]
Once in this temp table, I am trying to get the cursor to fill all gaps of column points as this column must be consecutive numbers.
Currently the table is something like this:
points type xxx
1 type7 123
2 type1 321
3 type3 654
5 type1 456
7 type9 987
15 type2 147
16 type2 789
17 type2 369
...
.....
Here is the code:
Code:
select * into #tmp_table from ProperTable
declare consecutive cursor for select * from #tmp_table
DECLARE @points ,@type ,@xxx
select @counter = 1
OPEN consecutive
FETCH YesterdayCursor
INTO @points ,@type ,@xxx
WHILE (@@sqlstatus = 0 )
begin
insert into ProperTable values (@points ,@type ,@xxx)
select @counter = @counter + 1
end
This code is obviously not compiling..
much grateful for any light you can shed for the newbie
[I have also tried doing this via sql update commands (from another thread) but this did not work so decided to go for the Cursor option.]