How to Delete Rows With a Join in SQL Server
Last updated July 25, 2026 · By the SaturnSQL team
Delete the alias, then join in FROM: DELETE o FROM orders o JOIN customers c ON ... Only rows from the aliased table are deleted; the join just decides which ones.
DELETE o
FROM orders o
JOIN customers c ON c.id = o.customer_id
WHERE c.is_test_account = 1;Count before you delete
SELECT COUNT(*)
FROM orders o
JOIN customers c ON c.id = o.customer_id
WHERE c.is_test_account = 1;On very large deletes, remove rows in batches with DELETE TOP (10000) in a loop to keep the transaction log and lock footprint manageable.
Run this in SaturnSQL
SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.
Try it free