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
Six unmarked stone tiles in a row in front of a plain wooden strip.

DATETRUNC: Use ISO Week Boundaries With Explicit Date Types

June 12, 2008
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Scripts, SQL Server

DATETRUNC can give an ISO week its Monday boundary without changing session settings. I also keep the input date type explicit. A boundary calculation should reveal both its calendar rule and its return type.

Read More
Slate-blue and sage ribbon loops around a wooden spindle, with a cream loop and vermilion end.

STRING_AGG Order: Keep NULLs and Type Width Visible

June 11, 2008
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Group By, SQL Server, SQL String

STRING_AGG order belongs inside WITHIN GROUP. This example preserves duplicate labels, shows how NULL differs from empty text and casts to nvarchar(max) before aggregation.

Read More
Gouache painting: under a market awning two wicker baskets of apricots stand apart

HAVING Without GROUP BY: Filter One Implicit Aggregate Group

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

HAVING without GROUP BY filters the single implicit aggregate group produced by the query. I use that distinction when a summary should appear only if its aggregate condition passes. A false condition can remove the summary row entirely.

Read More
Gouache painting of one jar of buttons being topped up by a small red scoop while spare empty jars stand unused

Compound Assignment Operators in T-SQL with Simple Examples

June 5, 2008
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Operator, SQL Scripts

Compound Assignment Operators let T-SQL do a calculation and an assignment in one step, so SET @Stock -= 2 replaces SET @Stock = @Stock – 2. This post tests all eight operators on SQL Server 2025 with a small garden center inventory. It also shows integer division, NULL, string and flag examples, and where the shorthand does not help.

Read More
SQL SERVER - Create a Comma Delimited List Using SELECT Clause From Table Column

SQL SERVER – Create a Comma Delimited List Using SELECT Clause From Table Column

June 4, 2008
Pinal Dave
SQL Tips and Tricks
CSV, Database, SQL Function, SQL Scripts, SQL Server, SQL Stored Procedure

I received following question in email : How to create a comma delimited list using SELECT clause from table column?

Read More
SELECT DISTINCT ResultDistinct.

SQL SERVER – Example of DISTINCT in Aggregate Functions

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

Does DISTINCT in Aggregate Functions make a difference? Yes. A quick AdventureWorks example compares SUM(DISTINCT ReorderPoint) with a plain SUM.

Read More
SQL SERVER - SQL SERVER - UDF - Get the Day of the Week Function - Part 4

SQL SERVER – SQL SERVER – UDF – Get the Day of the Week Function Part 4

June 1, 2008
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Scripts

In Day of the Week Function Part 4, I answer why I write a UDF when DATENAME exists (I just like it) and show the one line DATENAME version.

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

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