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
CASE Expression

SQL SERVER – Using CASE Expression in Default Value

July 21, 2021
Pinal Dave
SQL Tips and Tricks
SQL CASE, SQL Scripts, SQL Server, SQL Table Operation

It is not possible to use CASE Expression in Default Values when you add a new column. I hope this answers the question. However, there is a workaround.

Read More
A gardener walking a row of berry bushes with three small baskets on one strap, sorting berries in a single pass.

Conditional Aggregation: Several Counts in One Pass With CASE

June 24, 2021
Pinal Dave
SQL Tips and Tricks
PIVOT and UNPIVOT, SQL CASE, SQL Group By, SQL Scripts, SQL Server

Use conditional aggregation for several ticket counts, avoid COUNT with ELSE zero, and calculate percentages with an explicit denominator.

Read More
Unsolved CASE Expression

SQL Puzzle – Unsolved CASE Expression

April 20, 2021
Pinal Dave
SQL Puzzle
SQL CASE, SQL Scripts, SQL Server

Lots of people have asked me to share another puzzle. Well, let us see a very simple puzzle of Unsolved CASE Expression in today’s blog post.

Read More
order by a parameter

SQL SERVER – How to Order By a Parameter?

June 8, 2020
Pinal Dave
SQL Tips and Tricks
SQL CASE, SQL Order By, SQL Scripts, SQL Server

We figured out that there was a very poor code written in one of the Stored Procedure’s Order By clause. Let us learn today how to order by a parameter.

Read More
Three sorting bins in a row with a red rubber boot on the ground that fits none.

CASE Expression Pitfalls: NULL Tests and Data Type Precedence

April 20, 2013
Pinal Dave
SQL Tips and Tricks
SQL CASE, SQL Datatype, SQL NULL, SQL Server

Reproduce CASE expression traps with NULL tests, mixed result types, missing ELSE, and nesting, then apply clear rewrites.

Read More
  • Books
  • Testimonials
  • Privacy Policy

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