简体   繁体   中英

To identify special characters in a column in SQL

From the below sample data, I need to identify bank accounts which contain 'NULL' or values which contain special characters like . and +.

Please help with SQL query.

Country code        Country no.
CN                  1.41601002200003E+16
KR                  1081100499433
DK                  5005923427
GB                  20451053
CH                  86381881
SE                  51017374
CA                  101798545
AE                  90010200008612
AT                  NULL
US                  1134133639
BE                  220000422994
IT                  1264
CN                  1.1006058714634E+17
AT                  NULL

You can use like with exclusive character sets:

select t.*
from t
where t.country_no like '%[^0-9]%' or t.country_no is null;

If the issue is simply that large numbers don't "look" right, then convert them to a string:

select str(t.country_no, 20)
from t
where t.country_no like '%[^0-9]%' or t.country_no is null;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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