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 of a cream wrapped gift with a red ribbon on a patio table beside a pitcher of lemonade and a paper party hat

How to Calculate Age Correctly in SQL Server

July 30, 2008
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Scripts

Calculate Age in SQL Server by counting completed birthdays, not calendar years. This post compares DATEDIFF, a DATEADD correction and a compact integer version on a bike club table, handles February 29 birthdays and ends with a reusable function for age on any date.

Read More
A long pale wooden plank over a triangular support, beside a red wooden cube.

NULLIF Denominators: Keep Zero and Missing Values Visible

July 25, 2008
Pinal Dave
SQL Tips and Tricks
SQL Datatype, SQL Function, SQL NULL, SQL Server

NULLIF denominators turn zero into NULL for a deliberate division policy. This complete example keeps zero, missing inputs and integer truncation visible beside the decimal result.

Read More
A long looped slate-blue ribbon with ceramic beads and tassels at its ends beside a short gray ribbon.

REVERSE: Keep Trailing Spaces in String Reversal

July 11, 2008
Pinal Dave
SQL Tips and Tricks
SQL Datatype, SQL Function, SQL Server

REVERSE changes character order while keeping supplied spaces. Use visible boundaries and byte counts to distinguish empty and missing inputs.

Read More
A sage ceramic jar and a dark glass ink bottle on folded cream cloth beside a brass magnifying glass and vermilion cord.

COLLATIONPROPERTY CodePage: Identify Text Encoding

June 28, 2008
Pinal Dave
SQL Tips and Tricks
SQL Datatype, SQL Function, SQL Scripts

COLLATIONPROPERTY CodePage reports varchar encoding metadata. Compare code pages 1252 and 65001 without confusing inspection with text conversion.

Read More
Matching blue bowls occupy the upper-left compartments of two wooden display frames.

DATEPART Quarter: Keep the Year Beside the Quarter

June 26, 2008
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Reports, SQL Scripts, SQL Server

DATEPART quarter identifies a calendar component. I keep its year when reporting separate periods. A cross-year January case shows how quarter-only grouping combines events.

Read More
Two blue thread spools and one ochre spool stand on a metal support above folded cream fabric.

Weighted Average: Keep Group Totals and Value Counts

June 18, 2008
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Reports, SQL Scripts, SQL Server

A weighted average preserves each group’s contribution. I compare unequal groups before combining their means. Group totals and populated-value counts reconstruct the underlying average without treating missing readings as zero.

Read More
SQL SERVER - Introduction to SERVERPROPERTY and example

SQL SERVER – Introduction to SERVERPROPERTY and example

June 16, 2008
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Scripts

SERVERPROPERTY is a handy system function that returns server values like collation, edition and instance name. My script lists every property in one result.

Read More
Previous 1 … 66 67 68 69 70 71 72 … 92 Next
  • Books
  • Testimonials
  • Privacy Policy

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