• bitbucket-25253 (4/24/2011)


    Oh well, another question that does not rely on the workings of the database engine, but rather english comprehension.

    I would say you comprehended just fine.

    I would also say I do not see a concept or point being displayed by the question or it's explination. After furthur review...

    DECLARE @t TABLE

    (nDex INT IDENTITY(1,1)

    ,valu VARCHAR(9)

    ,keey UNIQUEIDENTIFIER)

    INSERT @t

    VALUES ('a',NEWID()) , ('b',NEWID())

    ,('c',NEWID()) , ('d',NEWID())

    ,('e',NEWID()) , ('f',NEWID())

    ,('g',NEWID()) , ('h',NEWID())

    ,('i',NEWID()) , ('j',NEWID())

    ,('k',NEWID())

    SELECT *

    INTO #gT from @t;

    DELETE t

    OUTPUT DELETED.*

    FROM @t AS t

    INNER JOIN (SELECT TOP 9 nDex

    FROM #gT

    ORDER BY keey) AS b

    ON b.ndex = t.nDex;

    DROP TABLE #gT;

    GO

    Seems that if you ORDER BY the name or alias of the column holding the NEWID() values and join to a #temp table of the records instead of the table you are deleting from (as you delete) the code always returns as I would expect it too.

    The other code would seem to never produce the same amount of joinable values to return...

    So why is "none of the above" the wrong answer?