ABS ABS - 北京怡康軟件科技有限公司 資源網(wǎng) "/>
返回給定數(shù)字表達(dá)式的絕對(duì)值。
ABS ( numeric_expression )
numeric_expression
精確數(shù)字或近似數(shù)字?jǐn)?shù)據(jù)類型類別的表達(dá)式(bit 數(shù)據(jù)類型除外)。
返回與 numeric_expression 相同的類型。
下例顯示了 ABS 函數(shù)對(duì)三個(gè)不同數(shù)字的效果。
SELECT ABS(-1.0), ABS(0.0), ABS(1.0)
下面是結(jié)果集:
---- ---- ----
1.0 .0 1.0
ABS 函數(shù)可能產(chǎn)生溢出錯(cuò)誤,例如:
SELECT ABS(convert(int, -2147483648))
下面是錯(cuò)誤信息:
Server: Msg 8115, Level 16, State 2
Arithmetic overflow error converting expression to type int.
相關(guān)文章