Getting Started with ASP.NET MVC - Part 5: How to do programming with razor syntax
First Time? You can support us by signing up. It takes only 5 seconds. Click here to sign up. If you already have an account, click here to login.


Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 113
sqlserver 94
BRH 78
#SQLServer 65
#TSQL 55
SQL Server 32
function 11
SSMS 9

Archive · View All
August 2007 17
August 2010 8
June 2011 7
November 2007 7
November 2011 6
August 2011 6
October 2011 6
July 2011 6
September 2011 6
December 2011 6

Madhivanan's TSQL Blog

How will you produce zero without using any numbers?

Jun 15 2011 9:25AM by Madhivanan   

Ok. Here is some Fun. This is the script that will produce zero without using any number in the code. Post your code if you find any such method

select 
	$,
	$+,
	$+.,
	-$,
	$*$,
	+$-,
	($),
	$.,
	($.),
	-+$-,
	+-$+.,
	-$+.+$.,
	'$,'-$+,
	'$,.'-$-.	

Run the code and see the output. Each column produces zero as a result.

Tags: t-sql, sql_server, sqlserver, tsql, BRH, SQL Server, #SQLServer, fun, symbol,


Madhivanan
4 · 39% · 8773
2
 
0
Lifesaver
 
0
Refreshed
 
 
0
Incorrect



Submit

23  Comments  

  • WOW! Never knew it!

    commented on Jun 15 2011 10:58AM  .  Report Abuse This post is not formatted correctly
    Pinal Dave
    144 · 1% · 280
  • look like, We can use any currency symbol, sql server supports.

    select £ --- Also returns "0"

    My guess is, when it sees any value/expression it tries to identify the datatype. Probably based on currency sumbol, it might identified it as "Money" datatype and showed default value for that...

    commented on Jun 15 2011 11:23PM  .  Report Abuse This post is not formatted correctly
    Ramireddy
    3 · 40% · 8881
  • Ramireddy you guess is right

    we can check by following sql

    SELECT cast(sqlvariantproperty($,'BaseType') as varchar(20))

    commented on Jun 16 2011 2:09AM  .  Report Abuse This post is not formatted correctly
    priyank
    1334 · 0% · 8
  • Yes....I saw this some time back some one using this..

    But i forgot it.....

    commented on Jun 16 2011 2:17AM  .  Report Abuse This post is not formatted correctly
    Ramireddy
    3 · 40% · 8881
  • Waiting for the Rupee symbol to get there :-)

    commented on Jun 16 2011 4:48AM  .  Report Abuse This post is not formatted correctly
    Jacob Sebastian
    1 · 100% · 22473
  • Ramireddy, you can use any currency symbol in place of dollor Jacob, we may get Rupee symbol soon

    commented on Jun 16 2011 5:26AM  .  Report Abuse This post is not formatted correctly
    Madhivanan
    4 · 39% · 8773
  • I have added some other methods in the code. You all may need to relook it.

    commented on Jun 16 2011 5:31AM  .  Report Abuse This post is not formatted correctly
    Madhivanan
    4 · 39% · 8773
  • I think expression $ is always considered as Money Datatype...we can check this also.. select len($)

    commented on Jun 16 2011 9:05AM  .  Report Abuse This post is not formatted correctly
    virenraval
    1539 · 0% · 6
  • Huh??!!! I guess SQL Server is more of a magic Pandoras box :) Superb! Thank-you for sharing!

    commented on Jun 16 2011 11:21AM  .  Report Abuse This post is not formatted correctly
    Nakul Vachhrajani
    6 · 26% · 5867
  • Cool..never knew about this!

    Could someone give a real-world scenario when/where this could be applied and why?

    TIA

    commented on Jun 16 2011 11:33AM  .  Report Abuse This post is not formatted correctly
    Aashish Thakker
    965 · 0% · 15
Previous 1 | 2 | 3 Next

Your Comment


Sign Up or Login to post a comment.

"How will you produce zero without using any numbers?" rated 5 out of 5 by 2 readers
How will you produce zero without using any numbers? , 5.0 out of 5 based on 2 ratings
    Copyright © Beyondrelational.com Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising