首页 > 解决方案 > 如何使用sql识别长值

问题描述

我需要检查文件上传列中收到的值是否具有exponential或长值。

例如,如果 value5.02E+13不是数字值 - 50100434157080,则需要使用格式不正确的消息来限制它。

为此,我在临时表中将上传内容从前端传递到后端,然后检查传递的值是否具有指数值或数值。

尝试使用 T-SQL 函数isnumeric(),但它没有给我预期的结果。还有其他可用的功能吗?

标签: sqlsql-servertsql

解决方案


由于您提到 usingisnumeric我假设您使用的是 SQL Server,在这种情况下您可以尝试try_cast,例如

select case when Try_Cast(Column as bigint) is null then 'not integer' else 'integer' end
from table

你也可以使用like

select case when Column like '%e%' then 'exponent' else 'number' end
from table

推荐阅读