SQL Server Science
Technical Articles for the DBA / Developer
Home » best practices

SQL Server hierarchyid: A Built-In Alternative to Recursive CTEs

2026-06-04 · by Hannah Vernon · in t-sql

Learn how SQL Server’s hierarchyid data type stores and queries tree structures without recursive CTEs, with practical examples for org charts and hierarchical data.

Recursive CTEs in SQL Server: How the Parts Actually Work Together

2026-06-03 · by Hannah Vernon · in t-sql

A plain-language walkthrough of recursive CTEs in SQL Server, breaking down the anchor, the recursive member, and the iteration cycle so the syntax finally makes sense.

A Better Cursor Pattern for SQL Server: Cursor Variables and @@CURSOR_ROWS

2026-06-02 · by Hannah Vernon · in t-sql

Replace the traditional WHILE @@FETCH_STATUS cursor loop with a cleaner pattern using cursor variables, STATIC cursors, and @@CURSOR_ROWS for more readable, less error-prone T-SQL.

Pick a Convention and Stick With It

2026-05-04 · by Hannah Vernon · in basics

You know what’s worse than a bad naming convention? Two naming conventions in the same database. I ran into this last week while writing a verification query for a PostgreSQL database. The query is a…

Search

Categories

  • AI for DBAs
  • announcements
    • events
  • basics
    • localization
  • configuration
  • Data Architecture
  • DMVs
  • documentation
  • extended-events
  • Git for DBAs
  • High Availability
  • Hot Takes
  • Internals
  • maintenance
    • patching
  • Opinion
  • performance
  • PostgreSQL
  • Professional Development
  • recovery
  • reporting
  • security
    • data security
  • service broker
  • SQL Server Agent
  • statistics
  • sys
  • t-sql
    • xml
  • tools
    • data masking
    • wsus
  • troubleshooting
  • Uncategorized

Pages

  • About SQL Server Science
  • Get Better Help with a Minimal, Complete, and Verifiable Example, or MCVE
  • Privacy Policy

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.

To find out more, including how to control cookies, see here: Cookie Policy

Copyright © 2026 SQL Server Science