• mister.magoo (6/27/2011)And the same thing re-written using a CTE - just to show an alternate way to format the code:

    ;WITH ToDelete AS

    (

    SELECT TOP (9) *

    FROM @t AS t

    ORDER BY

    NEWID()

    )

    DELETE ToDelete

    OUTPUT deleted.*

    Why did I bother posting this?.... well, I like this construct for updates mostly as the visual seperation of the SELECT from the UPDATE or the DELETE makes it entirely clear what you are doing - Here is the set of data I am interested in....now here is what I am going to do to it.

    I think it's much clearer that way and it makes it a little easier and less risky to move between select and delete without having a brainfart!