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

后端 未结 4 1254
挽巷
挽巷 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条回答
  •  时光说笑
    2021-02-20 13:53

    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
    

提交回复
热议问题