Hussein Fawzy Hussein Fawzy - 1 year ago 130
SQL Question

SELECT $ (dollar sign)

I have good experience in SQL Server,
But suddenly I discovered this strange




SELECT $ FROM tableName

All the time it returns zero scalar value (
or a new column with all values of

What is that?

Answer Source

When SQL Server comes across your $ sign, it automatically converts it into a money data type. Because you don't have an explicit value after the dollar sign, SQL Server is assuming 0.00. From MSDN:

When converting to money or smallmoney, integers are assumed to be monetary units. For example, the integer value of 4 is converted to the money equivalent of 4 dollars (for us_english, the default language). Numbers to the right of the decimal in floating-point values are rounded to four decimal places for money values. Expressions of data types char or varchar that are being converted to an integer data type must consist only of digits and an optional plus or minus sign (+ or -). Leading blanks are ignored. Expressions of data types char or varchar converted to money can also include an optional decimal point and leading dollar sign ($).