Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
In SQL server i found that when we write SELECT $ statement in sql server and execute it it returns 0.0 as answer.I need to know the reason for the same.
Posted
Comments
[no name] 17-Jul-13 9:00am    
Most likely whatever valid legitimate SELECT query that you are actually running is returning 0.0 because there are no valid records returned. Why that would be, we would have no idea since no one can read your mind.
RedDk 17-Jul-13 10:59am    
SELECT $ As [reason]

[reason]
~~~~~~~~~
0.00

confirmed output ...

1 solution

SELECT $ is equivalent to SELECT $0.00.
SQL Server uses the $ to indicate a Money Data Type. The documentation shows many different kinds of currency symbols that SQL Server recognizes.

See money and smallmoney (Transact-SQL)[^] documentation.

Prove to yourself that SQL Server uses the $ to indicate a Money Data Type by entering this query into SQL Server Management Studio:
SQL
select $2^3

or
SQL
select $^3

The error returned will be
Msg 402, Level 16, State 1, Line 1<br />
The data types money and int are incompatible in the '^' operator.

The error message talks about two data types.
$2 being the Money value and 3 being the int value.
 
Share this answer
 
v2
Comments
Maciej Los 17-Jul-13 9:21am    
Well explained...
+5!
Mike Meinz 17-Jul-13 13:13pm    
Maciej, Thank you very much for your vote. Somebody else voted "1". I wonder why.
Maciej Los 17-Jul-13 13:19pm    
Sometimes it happens ;( Dont' worry about it. There are people who can always up-vote good answer ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900