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
Punch needle beside a continuous stitched row with its last loose loop withdrawn

Gapless Invoice Numbers That Restart Every Year

October 25, 2012
Pinal Dave
SQL Tips and Tricks
SQL Scripts, SQL Server, SQL Transactions

Finance hates a missing invoice number. A small counter table and one short transaction keep the numbers gapless and restart them each year.

Read More
A sparrow leaving a birdbath taken by a big pigeon, flying toward a puddle beside a red tulip

SET LOCK_TIMEOUT and Error 1222: Waiting Less for Locks

September 13, 2012
Pinal Dave
SQL Performance
SQL Error Messages, SQL Lock, SQL Server, SQL Transactions

Set LOCK_TIMEOUT to bound lock waits, reproduce error 1222, clean up the transaction, and retry safely without confusing client timeouts.

Read More
A red high-jump bar hanging at a slant, one end still on its peg and the other on the landing mat

XACT_ABORT: Why a Half-Done Transaction Can Survive an Error

June 26, 2012
Pinal Dave
SQL Tips and Tricks
SQL Error Messages, SQL Server, SQL Stored Procedure, SQL Transactions

Use XACT_ABORT to prevent partial writes, inspect transaction state after an error, and build a TRY CATCH pattern with reliable rollback.

Read More
A row of identical lifebuoy rings hung on posts along a wooden harbor pier, the nearest one vermilion.

An Error Handling Template for Stored Procedures With THROW

June 11, 2012
Pinal Dave
SQL Tips and Tricks
Best Practices, SQL Error Messages, SQL Server, SQL Stored Procedure, SQL Transactions

Build an error handling template with XACT_ABORT, XACT_STATE, durable error logging, and THROW, then test a forced procedure failure.

Read More
Two hourglasses on a desk by a window, one tied with a red ribbon, beside a loose coil of rope.

Accelerated Database Recovery Quiz: Why Did the Rollback Finish at Once?

January 24, 2012
Pinal Dave
SQL Puzzle
SQL Performance, SQL Server 2019, SQL Transactions, Transaction Log

This Accelerated Database Recovery Quiz asks how long a rollback takes when ADR is on. The answer is almost no time, and a tested script measures the same rollback with ADR off and on. It also shows what ADR costs.

Read More
A sandcastle on a beach half washed away by the sea, and beside it a red bucket of shells that stayed dry.

Table Variables vs Temporary Tables Quiz: Which Survives a Rollback?

January 14, 2012
Pinal Dave
SQL Puzzle
SQL TempDB, SQL Transactions, SQL Variable, Temp Table

This Table Variables vs Temporary Tables Quiz inserts one row into each, then rolls back. The table variable keeps its row and the temporary table loses it. A tested script proves it, and two more scripts show a rollback-proof log and the statistics gap.

Read More
A pantry shelf where an old ceramic jar sits on a red tray beside the new jar that took its place.

OUTPUT Clause Quiz: What Do inserted and deleted Hold?

January 11, 2012
Pinal Dave
SQL Puzzle
Output Clause, SQL Delete, SQL Table Operation, SQL Transactions

This OUTPUT Clause Quiz raises a price from 10 to 12 and asks which two values come back. The answer is 10 and 12, because deleted holds the old row and inserted the new one. A tested script proves it and shows OUTPUT with INSERT, DELETE and an audit table.

Read More
Previous 1 … 6 7 8 9 10 11 12 … 15 Next
  • Books
  • Testimonials
  • Privacy Policy

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