T-sql - determine if value is integer

后端 未结 20 2158
情深已故
情深已故 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:35

    The following is correct for a WHERE clause; to make a function wrap it in CASE WHEN.

     ISNUMERIC(table.field) > 0 AND PATINDEX('%[^0123456789]%', table.field) = 0
    

提交回复
热议问题