Just curious... is there a command in TSQL which will delete rows I just selected from a table?
In pseudo SQL, something like
SELECT * FROM TableA THEN DELETE
Or
SELECT * FROM TableA WITH (DELETEROWS)
NOTE: I'm not just looking to delete rows, I want to return the rows to a temptable and then delete them, in the same statement
You can get the rows that were just deleted using the output clause:
DELETE FROM TableA
OUTPUT deleted.* --TODO name columns, identify table to insert into, etc
So, overall should be the same, just the order of operations is reversed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With