简体   繁体   English

SQL在数据中查找char

[英]SQL find char in data

i have a table have column that contain number and character. 我有一个表包含数字和字符的列。 how can i find the line that only contain the character? 我怎样才能找到只包含该字符的行? normaly this column can not be filled by character, but the user had make a many mistake 通常这个专栏不能用字符填充,但是用户犯了很多错误

example: 例:

Phone_Number
------------
02.23.35.65
02.32.65.87 EZERT
066565654
54541214 RTYR

i want to get this result: 我想得到这个结果:

02.32.65.87 EZERT
54541214 RTYR

i have tried with where Phone_Number like '%[0-9]%' and where Isnumeric(Phone_Number) = 0 我曾尝试使用where Phone_Number like '%[0-9]%'where Isnumeric(Phone_Number) = 0

select phone_number
from table
where  phone_number like '%[A-Z]%'

Try 尝试

SELECT * 
  FROM Table1
 WHERE Phone_Number LIKE '%[^.0-9]%'

or 要么

SELECT * 
  FROM Table1
 WHERE PATINDEX('%[^.0-9]%', Phone_Number) > 0

The query ensures that only valid characters are digits 0-9 and a comma. 该查询确保只有有效字符是数字0-9和逗号。 Meaning if any other than valid (not only [AZ]) characters are present it will catch it. 意思是如果除了有效(不仅仅是[AZ])字符以外的任何字符,它将捕获它。

Here is SQLFiddle demo 这是SQLFiddle演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM