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

后端 未结 4 1243
挽巷
挽巷 2021-02-20 13:11

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条回答
  •  旧时难觅i
    2021-02-20 13:53

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

提交回复
热议问题