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 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
Gouache painting of a jar of saved seeds beside a small red pot with a new green sprout on a garden bench

Restore a Database in SSMS: Step by Step

February 20, 2013
Pinal Dave
SQL Tips and Tricks
SQL Backup and Restore, SQL Scripts, SQL Server Management Studio

To restore a database in SSMS, right-click Databases, choose Restore Database, pick the backup file, name the destination and choose the recovery state. This post covers each page of the dialog, the tail-log error that stops overwrites, and the T-SQL for a full, differential and log restore chain.

Read More
Gouache painting of mechanical components organized in fitted compartments, with a selected impeller beside its empty storage recess.

SQL Server Version and Edition: SQL in Sixty Seconds #043

February 13, 2013
Pinal Dave
SQL Video
SQL in Sixty Seconds, SQL Instance, SQL Scripts, SQL Server Configuration

To find the SQL Server version and edition, read SERVERPROPERTY instead of parsing @@VERSION. The tests here show every useful property on SQL Server 2025, why ProductLevel can say RTM after an update, and how to read the version from the ERRORLOG.

Read More
TestTable clustered index.

SQL SERVER – Primary Key and NonClustered Index in Simple Words

February 10, 2013
Pinal Dave
SQL Tips and Tricks
SQL Index, SQL Scripts

In 2006 I wrote how Primary Key and Unique Key differ. Now I fill the gap and explain primary key and nonclustered index in simple words.

Read More
Previous 1 … 191 192 193 194 195 196 197 … 363 Next
  • Books
  • Testimonials
  • Privacy Policy

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