T-sql - determine if value is integer

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

    Here's a blog post describing the creation of an IsInteger UDF.

    Basically, it recommends adding '.e0' to the value and using IsNumeric. In this way, anything that already had a decimal point now has two decimal points, causing IsNumeric to be false, and anything already expressed in scientific notation is invalidated by the e0.

提交回复
热议问题