I have a problem finding a good way of moving data in a table without using a while loop.
I need to move the data in the table one step ahead. See my SQL code. Looping trough the data with a while loop is too slow a process.
My question is, is it possible to move a block of data instead?
DECLARE @Counter int, @popMen float, @CountLocal int, @maxLocal int
SET @Counter=110
SET @CountLocal=1
SELECT @maxLocal = Max(locaid) From population where (regiod=1)
WHILE (@CountLocal <= @maxLocal)
BEGIN
WHILE (@Counter >=0)
BEGIN
SELECT @popMen = popMen
from population where (regiod=1 AND locaid=@CountLocal AND age=@Counter)
SET @Counter=@Counter-1
SET @popMen=0
END
SET @CountLocal = @CountLocal + 1
SET @Counter=110
END