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
Aug10

FOR XML XSINIL: Emit Missing Fields as Explicit Nil Elements

Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Scripts, SQL Server, SQL XML
No Comments

FOR XML XSINIL can represent SQL NULL with an explicit element carrying the xsi:nil attribute. I compare that output with ordinary element omission. An empty string stays a separate input in both versions.

Continue Reading
Aug10

Aggregates With the OVER Clause: A Total Beside Every Row

Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Group By, SQL Scripts, SQL Server
3 Comments

Aggregates with the OVER clause put a total, an average or a minimum next to every row, so the rows do not collapse into one. This post uses eight trip costs to show the error a plain SUM gives, the fix, and the percent of the total for each row. It also shows how WHERE changes the total and how to filter on the result.

Continue Reading
Aug10

SQL Server: Use INSERT INTO SELECT Instead of a Cursor

Pinal Dave
SQL Tips and Tricks
Best Practices, SQL Scripts
37 Comments

Replace a row-by-row server inventory copy with INSERT INTO SELECT and test the results, including a loop that fails when IDs have gaps.

Continue Reading
Aug9

LIKE Character Ranges: [a-f], [^0-9] and Collation Traps

Pinal Dave
SQL Tips and Tricks
SQL Collation, SQL NULL, SQL String, Unicode
No Comments

A bracket range sounds simple until the collation decides what sits between a and f. Test it once so a bad code never reaches your table.

Continue Reading
Aug9

Overriding Identity Fields: Put a Deleted Row Back With Its Old ID

Pinal Dave
SQL Tips and Tricks
SQL Constraint and Keys, SQL Identity, SQL Scripts, SQL Server
3 Comments

Overriding identity fields is rare, but restoring a deleted row with its old ID needs it. This post uses IDENTITY_INSERT to put two workshops back with their old numbers. It shows the five errors you will meet, what happens to the next automatic number, and why gaps in an identity column are usually fine.

Continue Reading
Aug8

Many-to-Many Bridge Table in SQL Server: Model and Query It

Pinal Dave
SQL Tips and Tricks
Normalization, SQL Constraint and Keys, SQL Joins, SQL Scripts
1 Comment

A many-to-many bridge table links two tables that each have many partners in the other, such as orders and plants. This post builds one with a composite key and two foreign keys, then joins it three ways. It also shows what the keys block and why an inner join hides plants nobody ordered.

Continue Reading
Aug7

Dirty Records and Table Hints: Wait, Read Dirty, Skip or Fail

Pinal Dave
SQL Tips and Tricks
SQL Lock, SQL Scripts, SQL Transactions, Transaction Isolation
2 Comments

Dirty records and table hints decide what a SELECT does while another session has an uncommitted change. This post runs one update that rolls back and five readers against it: the default, READUNCOMMITTED, NOLOCK, READPAST and NOWAIT. It also shows how a database option changes the default.

Continue Reading
Previous 1 … 584 585 586 587 588 589 590 … 847 Next

SQL Server slow? Let's fix it together in about four hours.

Pinal Dave

In my Comprehensive Database Performance Health Check, you share your screen, I guide you, and we fix your biggest performance troublemakers. No passwords. No remote access.

You keep every script, and the know-how to fix it yourself next time.

Want your whole team to learn it?

My Practical Workshop has no PowerPoint, just live demos. My AI Enablement Workshop shows your team where AI saves hours, and where it quietly costs them.

Over 400 customers have worked with me this way, and not one shared a password. See all consulting options.


Who We Are

Pinal Dave is an SQL Server Performance Tuning Expert and independent consultant with over 24 years of hands-on experience. He holds a Masters of Science degree and numerous database certifications.

Pinal has authored 19 books and 125 Pluralsight courses. To freely share his knowledge and help others build their expertise, Pinal has also written more than 5,800 database tech articles on his blog at https://blog.sqlauthority.com.

Pinal is also a CrossFit Level 1 Trainer (CF-L1) and CrossFit Level 2 Trainer (CF-L2).


Nupur Dave is a social media enthusiast and an independent consultant. She primarily focuses on the database domain, helping clients build short and long-term multi-channel campaigns to drive leads for their sales pipeline.


Shaivi Pinalkumar Dave is a book author and a women’s artistic gymnast.

  • Books
  • Testimonials
  • Privacy Policy

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