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

后端 未结 4 1328
[愿得一人]
[愿得一人] 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:56

    DECLARE @value FLOAT = 1.50
    IF CONVERT(int, @value) - @value <> 0
    BEGIN
        PRINT 'this is float number'
    END
    ELSE
    BEGIN
        PRINT 'this is integer number'
    END
    

提交回复
热议问题