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
Gouache painting: seen from the side, a hillside of grapevines steps down in three terraces

hierarchyid GetLevel: Count the Path Depth

October 25, 2010
Pinal Dave
SQL Tips and Tricks
SQL Datatype, SQL Function, SQL Scripts, SQL Server

hierarchyid GetLevel identifies depth within a logical path. The read-only example distinguishes the root, children, grandchildren and a fractional sibling label.

Read More
SQL SERVER – Get Numeric Value From Alpha Numeric String – Get Numbers Only

SQL SERVER – Get Numeric Value From Alpha Numeric String – Get Numbers Only

September 25, 2010
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Scripts, SQL Stored Procedure, SQL String

Reader Christofer improved my logic to get a numeric value from alpha numeric string data. His stored procedure uses REVERSE and PATINDEX.

Read More
A whole watermelon beside one cut red slice on a cloth, a kitchen knife in front

Percent of Total With SUM() OVER() in One Query

September 18, 2010
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Reports, SQL Scripts, SQL Server

Calculate percent of total with SUM() OVER(), group and running shares, safe numeric division, and checks for zero totals.

Read More
Gouache painting: two shallow trays of turned wooden acorns, each holding both large and small acorns

REPLACE With COLLATE: Choose Case Matching Explicitly

September 17, 2010
Pinal Dave
SQL Tips and Tricks
SQL Collation, SQL Function, SQL Server

REPLACE with COLLATE controls which substrings match. Preview case-dependent results before applying a text replacement policy.

Read More
Gouache painting: three young apple trees stand in a row in a grassy orchard

FOR JSON PATH: Choose Whether NULL Properties Appear

September 5, 2010
Pinal Dave
SQL Tips and Tricks
SQL Datatype, SQL Function, SQL Scripts

FOR JSON PATH omits NULL properties by default. Compare INCLUDE_NULL_VALUES with missing properties and empty strings in a complete output example.

Read More
SQL SERVER – Function to Retrieve First Word of Sentence – String Operation

SQL SERVER – Function to Retrieve First Word of Sentence – String Operation

August 20, 2010
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Scripts, SQL String

A friend asked for a UDF that returns only the first word of a sentence. Here is my script with CHARINDEX and SUBSTRING, and how to turn it into a function.

Read More
Three terracotta bowls, one empty, beside a blue tray with three circular recesses.

CROSS APPLY Aggregate: An Empty Input Can Still Return a Row

August 18, 2010
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Joins, SQL Scripts, SQL Server

CROSS APPLY aggregate behavior depends on whether the right-side query actually produces a row. I inspect that query before assuming unmatched customers disappear. An aggregate without GROUP BY can return a row even when its input is empty.

Read More
Previous 1 … 47 48 49 50 51 52 53 … 92 Next
  • Books
  • Testimonials
  • Privacy Policy

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