使用 SQL 检查列是否包含文本

Check if a column contains text using SQL(使用 SQL 检查列是否包含文本)
本文介绍了使用 SQL 检查列是否包含文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个名为 studentID 的列,但我有 数百万 条记录,并且应用程序以某种方式在其中输入了一些任意文本列.

I have a column which is called studentID, but I have millions of records and somehow the application has input some arbitrary text in the column.

我如何搜索:

SELECT *
  FROM STUDENTS
 WHERE STUDENTID CONTAINS TEXT

推荐答案

将数据库建模问题放在一边.我觉得你可以试试

Leaving database modeling issues aside. I think you can try

SELECT * FROM STUDENTS WHERE ISNUMERIC(STUDENTID) = 0

但是 ISNUMERIC 对任何看起来像数字的值返回 1,包括 -1.0e5

But ISNUMERIC returns 1 for any value that seems numeric including things like -1.0e5

如果您想排除纯数字的学生 ID,请尝试类似

If you want to exclude digit-only studentids, try something like

SELECT * FROM STUDENTS WHERE STUDENTID LIKE '%[^0-9]%'

这篇关于使用 SQL 检查列是否包含文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert varchar to float IF ISNUMERIC(将 varchar 转换为 float IF ISNUMERIC)
multi part identifier could not be bound sql(无法绑定多部分标识符 sql)
Any benefit to explicitly dropping local temporary tables at the end of a stored procedure?(在存储过程结束时显式删除本地临时表有什么好处?)
Select value if condition in SQL Server(SQL Server 中的条件选择值)
Control flow in T-SQL SP using IF..ELSE IF - are there other ways?(使用 IF..ELSE IF 在 T-SQL SP 中控制流 - 还有其他方法吗?)
Inserting a multiple records in a table with while loop (使用while循环在表中插入多条记录)