sql - 如何使用sql识别长值
问题描述
我需要检查文件上传列中收到的值是否具有exponential
或长值。
例如,如果 value5.02E+13
不是数字值 - 50100434157080,则需要使用格式不正确的消息来限制它。
为此,我在临时表中将上传内容从前端传递到后端,然后检查传递的值是否具有指数值或数值。
尝试使用 T-SQL 函数isnumeric()
,但它没有给我预期的结果。还有其他可用的功能吗?
解决方案
由于您提到 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
推荐阅读
- apache-kafka - Spring kafka 和 Kafka 集群
- excel - 循环遍历目录(需要帮助添加第二个范围)
- ruby - 只留下第二个数字的正则表达式
- javascript - 具有嵌套函数的节点异步函数
- sql - Redshift 或 ANY SQL:更新具有相似行且时间在 30 秒内的表
- bash - 无法从单行命令回显 bash 变量
- javascript - Object.create({}) 之间的区别 {}
- primefaces - Mojarra 上的 PrimeFaces TreeTable 问题
- sql - 根据 Teradata SQL 中另一列的最大值查找列计数
- sql - 将带有内部连接的更新查询从 vba 转换为 SQL Server