T-sql - determine if value is integer

后端 未结 20 2209
情深已故
情深已故 2020-11-30 12:11

I want to determine if a value is integer (like TryParse in .NET). Unfortunatelly ISNUMERIC does not fit me because I want to parse only integers a

20条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 12:48

    See whether the below query will help

    SELECT *
    FROM MY_TABLE
    WHERE CHARINDEX('.',MY_FIELD) = 0 AND CHARINDEX(',',MY_FIELD) = 0       
    AND ISNUMERIC(MY_FIELD) = 1 AND CONVERT(FLOAT,MY_FIELD) / 2147483647 <= 1
    

提交回复
热议问题