On PostgrSQL its no problem for me to do this:
CREATE SEQUENCE serial_olw START 1;
update collections_elements set elementorder=(nextval('serial_olw')-1) WHERE collections_elements.collectionid=1;
drop sequence serial_olw;
Example: 1,2,3,4,5,6…
On a MS-SQL Server 2008 there is not a function SEQUENCE… so I tried this:
DECLARE @i int
SET @i = 0
WHILE @i<44
BEGIN
UPDATE collections_elements set elementorder=(@i) WHERE collections_elements.collectionid=1
SET @i=@i+1
END
But I have no success with that loop…
Example: 43,43,43,43,43…
Any ideas for a solution?
SQL Fiddle