SQL SERVER – Solution – Generating Zero Without using Any Numbers in T-SQL

SQL Server MVP and my friend Madhivanan has asked very interesting question on his blog regarding How to Generate Zero without using Any Numbers in T-SQL. He has demonstrated various methods how one can generate Zero. When I posted note regarding how one he has generated Zero without using number in my blog post for Free Online Training, blog readers have come up with few very interesting answers. I really found them very interesting and here I am listing them with due credit.

SQL SERVER - Solution - Generating Zero Without using Any Numbers in T-SQL

Special mention to Andery.ca as the answer Andery provided is the one, I myself come up with after very first look and that is why I had left the same as hint in the original article.

anil

try this
select count(cast(null as int))
or
any false condition
select count(*) where ‘a’=’b’

Varinder Sandhu

It seems every currency symbol that SQL Server supports. Return the same value as zero

i tried some as

select €
 select ¥
 select £

Andrey.ca

select count(*)-count(*)

Vinay Kumar

Another way for generate zero.

select Ascii(‘Y’)-Ascii(‘Y’)
 OR
 select LEN(”)

I like Madhivanan’s answer. and it was awesome.

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.

Previous Post
SQL SERVER – Solution – Puzzle – Statistics are not Updated but are Created Once
Next Post
SQL SERVER – Puzzle Involving NULL – Resolve – Error – Operand data type void type is invalid for sum operator

Related Posts

No results found.

15 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.