How to determine whether the number is float or integer in SQL Server?

后端 未结 4 1327
[愿得一人]
[愿得一人] 2021-02-20 13:17

I need to write this query in sql server:

IF isFloat(@value) = 1
BEGIN
    PRINT \'this is float number\'
END
ELSE
BEGIN
    PRINT \'this is integer number\'
END         


        
4条回答
  •  南方客
    南方客 (楼主)
    2021-02-20 13:54

    declare @value float = 1
    
    IF FLOOR(@value) <> CEILING(@value)
    BEGIN
        PRINT 'this is float number'
    END
    ELSE
    BEGIN
        PRINT 'this is integer number'
    END
    

提交回复
热议问题