This month's discount Comprehensive Database Performance Health Check · Testimonials
SQLAuthority with Pinal Dave
Home
  • Consulting
    • Health Check
  • Free Videos
  • All Articles
    • AI
    • SQL Performance
    • SQL Tips and Tricks
    • Interview Questions and Answers
    • SQL Puzzle
    • SQL Video
    • SQLAuthority News
    • Personal
  • Books
  • Consulting
A library trolley carrying a small stack of old books toward a basement stairway, a gap left on the shelf.

Archiving Old Rows to a History Table in Small Batches

February 3, 2020
Pinal Dave
SQL Tips and Tricks
Batch, Output Clause, SQL Delete, SQL Server, SQL Transactions

Make archiving old rows atomic with DELETE OUTPUT, preserved source identifiers, bounded batches, reconciliation, and a job time limit.

Read More
Gouache painting of three garden beds in a row with a hoe whose grip is vermilion

Delete the Wrong Row: A Cheap Answer That Passes the Test

August 8, 2019
Pinal Dave
SQL Puzzle
SQL Delete, SQL Performance, SQL Scripts

A cheap answer to the multiple table delete puzzle reads only 6 pages and passes the check. It can still delete the wrong row. This post shows the answer, asks you to find the row it removes by mistake, and fixes it with a delete that costs 5 reads.

Read More
Gouache painting of three potted plants on a stepped stand with a vermilion rosette on the tallest

Fewest Logical Reads: The Answer to the Delete Qualified Rows Puzzle

July 29, 2019
Pinal Dave
SQL Puzzle
SQL Delete, SQL Performance, SQL Scripts

The fewest logical reads for the multiple table delete puzzle come from reading each table as few times as the rules allow. A string of student IDs gets to 4 reads. A set based delete needs 5 and is the one to use. The starting script needed 19.

Read More
Gouache painting of a picket fence in a meadow with one vermilion picket leaning the opposite way

SQL Agent Job Backslash Puzzle: Why Both Rows Were Deleted

July 18, 2019
Pinal Dave
SQL Puzzle
SQL Delete, SQL Scripts, SQL Server Agent

A SQL Agent job backslash at the end of a comment line can turn a one row delete into a delete of the whole table. This puzzle sets up the job, explains the cause and tests the effect in T-SQL. It ends with a safe way to write the step.

Read More
Gouache painting of three wooden shape sorter boxes with a single vermilion peg in front of them

Delete Qualified Rows From Multiple Tables: A SQL Puzzle

July 13, 2019
Pinal Dave
SQL Puzzle
SQL Delete, SQL Performance, SQL Scripts

Delete qualified rows from multiple tables with as few logical reads as you can. This puzzle gives a setup script for three small tables, the two rules for the delete and a starting script that costs 19 logical reads. Your task is to beat that number and stay correct.

Read More
A small red boat ferrying a few crates at a time from a big heap on one quay to a pile across the water

Deleting Millions of Rows in Batches Without Filling the Log

August 9, 2016
Pinal Dave
SQL Performance
Batch, SQL Delete, SQL Server, Transaction Log

Plan deleting millions of rows with bounded commits, an indexed cutoff, log reuse checks, and a clear choice of retention method.

Read More
An empty extended bicycle repair stand takes more floor space than an identical folded stand

Deleting From a Heap: Why Empty Pages Stay Behind

May 27, 2015
Pinal Dave
SQL Tips and Tricks
SQL Data Storage, SQL Delete, SQL Heap

The rows are gone but the table is the same size and scans are just as slow. Here is why, and two ways to fix it.

Read More
Previous 1 2 3 4 Next
  • Books
  • Testimonials
  • Privacy Policy

© 2006 – 2026 All rights reserved. pinal @ SQLAuthority.com