Tag archive
Commands grouped around the same concept, pattern, or recurring problem.
Use `ROW_NUMBER()` to identify duplicate rows and delete every copy except the one you want to keep.
Remove child rows that reference missing parent rows before enforcing referential integrity.
Remove matching rows with `DELETE`, then query the remaining table contents.
Remove rows from one table when a matching row exists in another table using a subquery.
Remove rows from one table based on matching rows in another table.
Delete every row in a table quickly with TRUNCATE TABLE, which is faster than DELETE with no WHERE clause.
Use `MERGE` to insert new rows, update matching ones, and delete rows that should be removed — all in a single statement against a source table.