SQL SERVER – Puzzle – Write a Shortest Code to Produce Zero

This Zero puzzle asks for the shortest SQL Server code within three restrictions. I want the exact code and character count.

A compact fitting sits within two stops while a longer candidate remains outside the allowed gap.

  1. Don’t use numbers or arithmetic calculations.
  2. Don’t include the digit 0 in the code.
  3. Don’t use LEN().
  4. The submitted code must be shorter than 18 characters.

This is the starting example. It returns the required value, but exceeds the final character limit.

SELECT ISDATE('a')

It returns 0 and contains 18 characters, including the space after SELECT. It therefore demonstrates the allowed result, but is not short enough to satisfy the final condition. SELECT 1-1, PRINT 0 and SELECT LEN(”) break the earlier rules.

Try a solution and include its exact character count. Compare it against every restriction before posting. I’m keeping the challenge open for readers.

A short expression is not a valid puzzle answer by itself, it is an answer only when every restriction holds.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

SQL Function, SQL Scripts, SQL Server
Previous Post
SQL SERVER – Puzzle – Incorrect Results with Decimal
Next Post
SQL SERVER – Select Unique Data From a Column Exist in Two Different Table

Related Posts

726 Comments. Leave new

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.