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
A row of rain gauges holding different amounts of water

Grouping Dates Into Buckets With DATE_BUCKET

September 14, 2007
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Server, SQL Server 2022

DATE_BUCKET groups timestamps into hourly, weekly, and custom intervals, with an origin that determines where every boundary lands.

Read More
Two glass jars stand side by side, one empty and one holding red seeds.

COUNT_BIG: Count Rows and Non-NULL Values as bigint

September 12, 2007
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL NULL, SQL Scripts, SQL Server

COUNT_BIG helps me name the counting rule before reading the result. Compare rows, supplied values and distinct readings. Then check empty results and the bigint return type.

Read More
Three empty rectangular ceramic dishes in a wooden tray beside a blank cream folio and vermilion ribbon.

FORMATMESSAGE: Build a Message Without Raising an Error

September 11, 2007
Pinal Dave
SQL Tips and Tricks
SQL Datatype, SQL Function, SQL Scripts

FORMATMESSAGE returns formatted text without raising an error. Match placeholders to typed arguments and keep formatting separate from control flow.

Read More
Two brass keys beside a small open wooden cabinet, one hanging inside and one resting on blue cloth.

RIGHT: Zero Padding Can Remove Significant Digits

September 10, 2007
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Scripts, SQL Server, SQL String

RIGHT can make zero padding look correct while quietly removing significant digits. I validate the allowed numeric range before creating a fixed-width label. The suffix expression alone cannot tell whether the input fits.

Read More
SQL SERVER - UDF - User Defined Function - Get Number of Days in Month

SQL SERVER – UDF – User Defined Function – Get Number of Days in Month

September 8, 2007
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Scripts

A simple user defined function that returns the number of days in month for any date, with the leap year rule for February built in.

Read More
Gouache painting: on a market counter a pink grapefruit has had one thin wedge cut from it, and the wedge lies on a small saucer

RADIANS: Cast Integer Degrees Before Conversion

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

RADIANS changes degrees into radians, but its input type affects the result. The example contrasts integer and float arguments while keeping the original degree values.

Read More
Two small terracotta bowls and one large pale bowl holding blue pebbles, with one vermilion pebble in the large bowl.

GROUPING_ID: Separate Stored NULL Values From ROLLUP Totals

August 26, 2007
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Reports, SQL Scripts, SQL Server

GROUPING_ID helps me distinguish a stored NULL from a subtotal created by ROLLUP. Both can appear in the same column. I keep the grouping bits beside the numbers before adding presentation labels.

Read More
Previous 1 … 78 79 80 81 82 83 84 … 92 Next
  • Books
  • Testimonials
  • Privacy Policy

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