【发布时间】:2016-03-09 21:08:00
【问题描述】:
我一直在查看下面转载的 this code,,它寻找非 ASCII 字符...
select line,
patindex('%[^ !-~]%' COLLATE Latin1_General_BIN, Line) as [Position],
substring(Line, patindex('%[^ !-~]%' COLLATE Latin1_General_BIN, Line), 1) as [InvalidCharacter],
ascii(substring(line, patindex('%[^ !-~]%' COLLATE Latin1_General_BIN, Line), 1)) as [ASCIICode]
from staging.APARMRE1
where patindex('%[^ !-~]%' COLLATE Latin1_General_BIN, Line) > 0
我想为'%[^ !-~]%' COLLATE Latin1_General_BIN 声明一个变量而不是每次都写出来,但
declare @regex varchar(20) = '%[^ !-~]%' COLLATE Latin1_General_BIN;
select line,
patindex(@regex, Line) as [Position],
substring(Line, patindex(@regex, Line), 1) as [InvalidCharacter],
ascii(substring(line, patindex(@regex, Line), 1)) as [ASCIICode]
from staging.APARMRE1
where patindex(@regex, Line) > 0
只是不做同样的事情。我只是缺少一些语法吗?不可能吗?
【问题讨论】:
标签: sql sql-server tsql collate