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,
WOW! Never knew it!
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...
Ramireddy you guess is right
we can check by following sql
SELECT cast(sqlvariantproperty($,'BaseType') as varchar(20))
Yes....I saw this some time back some one using this..
But i forgot it.....
Waiting for the Rupee symbol to get there :-)
Ramireddy, you can use any currency symbol in place of dollor Jacob, we may get Rupee symbol soon
I have added some other methods in the code. You all may need to relook it.
I think expression $ is always considered as Money Datatype...we can check this also.. select len($)
Huh??!!! I guess SQL Server is more of a magic Pandoras box :) Superb! Thank-you for sharing!
Cool..never knew about this!
Could someone give a real-world scenario when/where this could be applied and why?
TIA