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

- Don’t use numbers or arithmetic calculations.
- Don’t include the digit 0 in the code.
- Don’t use LEN().
- 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.





726 Comments. Leave new
SELECT ISNUMERIC(null)
Select isdate(”)
SELECT ISNUMERIC(”)
print @@TRANCOUNT
SELECT CHAR(48)
Condition 1… ;)
print @@error
Select isnumeric(‘A’)
SELECT sin(0)
You used 0
SELECT ISDATE(”)
select pi()-pi()
that’s arithmetic calculation
Not the shortest posted, but a bit different …
SELECT”&@@IDLE
returns int 0
SELECT”&@@SPID
returns smallint 0
Not sure if PRINT is permitted, but that works too.
he mentions it on the description PRINT 0 is not allowed because the 0 not the PRINT it selft
PRINT ABS(”)
PRINT SIN(\)
— Result 0 (zero). Code length 12.
— Currency symbols for the SIN argument also return zero. Like…
PRINT SIN($) — Mexican Peso
— and others
PRINT SIN($) — US Dollar
PRINT SIN(£) — UK Pound
— etc…
I got 6!