可以
SELECT CAST(2.083 AS float) AS c
以更紧凑的方式编写吗?
类似
SELECT 2.083f AS c
?
答案 0 :(得分:3)
要避免将CAST
显露到float
,请指定floating point constant expression:
--these both return float with precision 53
EXEC sp_describe_first_result_set N'SELECT CAST(2.083 AS float) AS c;';
EXEC sp_describe_first_result_set N'SELECT 2.083E0 AS c;';
--without scientific notation, the constant is interpreted as numeric(4,3)
EXEC sp_describe_first_result_set N'SELECT 2.083 AS c;';