• Using SQL Server 2005, there's an interesting and really fast way to do it. You should read all the explanation and be sure to understand it before using it. You should test that it works correctly before full implementation.

    The explanation is here:

    http://www.sqlservercentral.com/articles/T-SQL/68467/

    And the example is here:

    WITH SampleData(Pos, item, SID) AS(

    SELECT 1, 'tire', 1 UNION ALL SELECT

    NULL, 'black', 2 UNION ALL SELECT

    NULL, '50 $', 3 UNION ALL SELECT

    2, 'car jack', 4 UNION ALL SELECT

    NULL, 'blue', 5 UNION ALL SELECT

    NULL, '35 $', 6 UNION ALL SELECT

    3, 'screwdriver', 7 UNION ALL SELECT

    NULL, 'red', 8 UNION ALL SELECT

    NULL, '3 $', 9)

    SELECT *

    INTO #Samp

    FROM SampleData

    CREATE CLUSTERED INDEX SampID ON #Samp(SID)

    SELECT *

    FROM #Samp

    DECLARE @Pos int, @anchor varchar(100)

    SELECT TOP 1 @Pos = Pos

    FROM #Samp

    ORDER BY SID

    UPDATE a SET

    @Pos = Pos = ISNULL( Pos, @Pos),

    @anchor = item

    FROM #Samp a WITH (TABLOCKX)

    OPTION (MAXDOP 1)

    SELECT *

    FROM #Samp

    DROP TABLE #Samp

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2