-
commented on Jun 15 2011 10:58AM
|
-
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
|
-
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
|
-
Yes....I saw this some time back some one using this..
But i forgot it.....
commented on Jun 16 2011 2:17AM
|
-
Waiting for the Rupee symbol to get there :-)
commented on Jun 16 2011 4:48AM
|
-
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
|
-
I have added some other methods in the code. You all may need to relook it.
commented on Jun 16 2011 5:31AM
|
-
I think expression $ is always considered as Money Datatype...we can check this also..
select len($)
commented on Jun 16 2011 9:05AM
|
-
Huh??!!! I guess SQL Server is more of a magic Pandoras box :) Superb! Thank-you for sharing!
commented on Jun 16 2011 11:21AM
|
-
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
|
-
Excellent trick...!!
Thanks for sharing..
commented on Jun 21 2011 2:10AM
|
-
commented on Jun 23 2011 3:43PM
|
-
Really great !!! Never knew it. Thanks for sharing.
commented on Jul 5 2011 3:50AM
|
-
Hi Madhi, here is my try...
SELECT (ASCII('A')-ASCII('A'))+$
commented on Jul 5 2011 4:28AM
|
-
select convert(int,'') will produce zero but '' as is (not converted char) is not numeric - and its logic ;)
commented on Jul 8 2011 3:25AM
|
-
Yet another way . . .
declare @zero bit;
set @zero = 'false';
select convert(int, @zero) as zero;
Still don't know why I'd ever need to do this.
commented on Jul 8 2011 8:42AM
|
-
Select cast('' as int)
Select floor(rand())
Select datediff(mi,'','')
Select min(number) from master.dbo.spt_values where type='P'
Select count() From sys.databases Where 'A'='B'
Select count()-count(*) From sys.databases -- could be any table
Select min(status) from sys.systypes
Easy to find a lot of other ways... ;) those are just the first that crossed my mind
commented on Jul 8 2011 8:50AM
|
-
cool, I guess now we can use currency symbols too
commented on Jul 8 2011 9:10AM
|
-
commented on Jul 8 2011 11:20AM
|
-
csanabria, it is useful it you want to ask a tricky interview question
commented on Jul 11 2011 1:08AM
|