您好我需要跳过可能包含文字的行
示例:我有表OUTSTANDING
,我的字段在下面给出。
INVOICENO
AB1
111
ZX3
我需要跳过包含AB1
和ZX3
的行,并选择包含111
的行
我试过这个查询
"SELECT * FROM [INT]..OUTSTANDING WHERE INVOICENO NOT LIKE '%[a-z,-]%'";
答案 0 :(得分:1)
尝试:
"SELECT * FROM [INT]..OUTSTANDING WHERE NOT INVOICENO LIKE '%[0-9]%'";
或
...where INVOICENO not like '%[a-z]%'
除非需要更高级的正则表达式....
来源:http://www.sqllion.com/2010/12/pattern-matching-regex-in-t-sql/
答案 1 :(得分:1)
Select *
FROM [INT]..OUTSTANDING
WHERE IsNumeric(INVOICENO ) = 1
And INVOICENO Is Not NULL
答案 2 :(得分:0)
WHERE ISNUMERIC(INVOICENO) = 1
答案 3 :(得分:0)
尝试以下方法:
方法1:
SELECT *
FROM [INT]..OUTSTANDING
WHERE InvoiceNo IS NOT NULL
AND ISNUMERIC(InvoiceNo)=1
方法2:
SELECT *
FROM [INT]..OUTSTANDING
WHERE InvoiceNo IS NOT NULL
AND INVOICENO NOT LIKE '%[^0-9]%'