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
Two boxes. The path /Library/Book in nodes() returns 3 rows, one per book. The path /Library/Book/Reviewer returns 5 rows, one per reviewer, each with its BookID, rank and reviewer name

nodes() Method in SQL Server: Aliases and Row Patterns

March 1, 2013
Pinal Dave
SQL Tips and Tricks
SQL Scripts, SQL Server, SQL XML

The nodes() method turns each element at a path into one row you can query. This post builds a small catalog of books and reviewers, and shows the two alias errors, query() against value(), the singleton rule, how the row pattern decides the rows, and CROSS APPLY for the next level. Every result comes from SQL Server 2025.

Read More
A table of FORMAT strings for 2024-08-12: MMMM gives August, MMM gives Aug, MM gives 08. Beside it, for 9:22:38 pm, MM gives 10, mm gives 22, HH gives 21, hh gives 09 and ss gives 38

Custom Date Format Strings in SQL Server: MM Is Not mm

February 28, 2013
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Scripts, SQL Server

Custom date format strings tell FORMAT exactly which parts of a date to show. This post compares CONVERT styles with FORMAT, lists the standard and custom letters, and shows the traps: MM against mm, YYYY against yyyy, month names that sort wrong, and a culture that changes with the session. Every result comes from SQL Server 2025.

Read More
Gouache painting of a circular wooden card carousel feeding a selected blue card into a separate tray.

Cycle Clipboard Ring in SSMS: SQL in Sixty Seconds #045

February 27, 2013
Pinal Dave
SQL Video
SQL in Sixty Seconds, SQL Scripts, SQL Server Management Studio, SQL Shortcut

To cycle clipboard ring entries in SSMS, press Ctrl+Shift+V after a paste. The clipboard ring is most useful when you copy several names, so this post uses T-SQL to build clean column lists and tests the QUOTENAME and STRING_AGG limits that break a paste.

Read More
Two maps. On the left, six land parcels drawn as rectangles. On the right, the same land merged by owner into three shapes: School 78, Club 80 and Town 8 square units, with all land merged into one polygon of 158

Spatial Unions in SQL Server: STUnion and UnionAggregate

February 27, 2013
Pinal Dave
SQL Tips and Tricks
Spatial Database, SQL Datatype, SQL Scripts, SQL Server

Spatial unions merge shapes that touch or overlap into one shape. This post uses six land parcels on a flat grid to show STContains, STUnion for two shapes, chained unions, UnionAggregate with GROUP BY, and CollectionAggregate for comparison. Every area and result comes from SQL Server 2025.

Read More
Three boxes for the same eight pledges: a plain SUM returns 1 row holding 4,800.00, GROUP BY MemberID returns 6 rows, one per member, and SUM with OVER returns all 8 rows, each with the total

Aggregate and Detail Columns in One Query: GROUP BY or OVER

February 26, 2013
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Group By, SQL Scripts, SQL Server

Aggregate and detail columns in one query fail with Msg 8120 until you pick a way to keep the rows. This post compares GROUP BY, a scalar subquery and OVER on one small table, adds PARTITION BY and a share of the total, and then combines GROUP BY with OVER. Every result comes from SQL Server 2025.

Read More
Two panels. On the left, a join query with a gray comment line and a note about dashes and block marks. On the right, the same query without the comment, followed by its five result rows.

Why We Use Code Comments in SQL Server: Say Why, Not What

February 25, 2013
Pinal Dave
SQL Tips and Tricks
SQL Coding Standards, SQL Documentation, SQL Scripts, SQL Server

Why we use code comments comes down to one habit: write the reason, not the action. This post uses a small library table to show single-line and block comments, commenting out a join to test a theory, the Msg 156 trap, nested comments, and whether comments slow a query. Every result comes from SQL Server 2025.

Read More
Biscuit joiner set against one timber joint beside an untouched matching joint

QUERY_OPTIMIZER_HOTFIXES: Turning On Optimizer Fixes per Database

February 24, 2013
Pinal Dave
SQL Performance
SQL Performance, SQL Scripts, SQL Server

A vendor says to turn on optimizer hotfixes. Here is how I check the setting, try it on one statement, and restore it.

Read More
Previous 1 … 496 497 498 499 500 501 502 … 844 Next
  • Books
  • Testimonials
  • Privacy Policy

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