You're not really supposed to be seeing this.. site is a work in progress.. but feel free to bookmark lert.us and come back later!

Simple Batch Delete

eilert - 1900-01-01 00:00:00.00

Sometimes you may find yourself working with a very large table and you need to delete a ton of records.

For example, let's say you need to delete 32 million rows, but your system might choke a little deleting them all in one go, but your particular setup could handle 1 million rows at a time

First, check that there is an index on the columns you're filtering on for the delete.

Then, see how many batches of deletes you'll need.

Then use the "GO" keyword in SSMS or Azure Data Studio to execute that many times (+1)

About Me

Image

I've been working with SQL Server for the last 12 years and have found it to be a marvelous data platform. I love writing SQL and sharing my knowledge.

Follow Me

Some text..