SELECT $ (dollar sign)

前端 未结 3 1466
不思量自难忘°
不思量自难忘° 2020-12-18 17:57

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

SELECT $ 

or

SE         


        
3条回答
  •  渐次进展
    2020-12-18 18:33

    After a little messing around, I've figured since this happens no matter what currency symbol is used, SQL server is implying that the field is a currency field.

    If you add numbers after the currency symbol, in this case a dollar so:

    SELECT $4
    

    SQL server will return 4.00

    So SQL Server is taking the use of $ and assuming we want to create a field with the MONEY datatype and as we haven't entered a value after the currency symbol, SQL Server assumes the value is 0, though in my opinion this should return NULL.

提交回复
热议问题