If use the select statement:
select top (18) * from pippo;
And I use the delete statement:
delete top (18) from pippo;
I would like to know if the 18 selected and deleted rows are the same.
Any help?
EDIT after having accepted the answer:
I have found the following solution here: Delete the 'first' record from a table in SQL Server, without a WHERE condition
WITH q AS
(
SELECT TOP 18 *
FROM pippo
ORDER BY FIELD1 ASC /* You may want to add ORDER BY here */
)
DELETE
FROM q
With this solution I sort all the “pippo” table by FIELD1, and then I delete the first 18 rows.
Without an order by clause, there is no guaranteed ordering so no, they are not guaranteed to be the same.