あなたはT-SQLのLIKE
であなたが求めていることをすることはできません。
あなたの最善の策は、Common Language Runtime (CLR)を使用して見ているが、それはまた次のように、例えば、スカラー値関数を使用して(ゆっくり痛々しいが)実現することができます。
create function dbo.ContainsRepeatingAlphaChars(@str nvarchar(max)) returns bit
as begin
declare @p int, -- the position we're looking at
@c char(1) -- the previous char
if @str is null or len(@str) < 2 return 0;
select @c = substring(@str, 1, 1), @p = 1;
while (1=1) begin
set @p = @p + 1; -- move position pointer ahead
if @p > len(@str) return 0; -- if we're at the end of the string and haven't already exited, we haven't found a match
if @c like '[A-Z]' and @c = substring(@str, @p, 1) return 1; -- if last char is A-Z and matches the current char then return "found!"
set @c = substring(@str, @p, 1); -- Get next char
end
return 0; -- this will never be hit but stops SQL Server complaining that not all paths return a value
end
GO
-- Example usage:
SELECT field1
FROM exampleTable
WHERE dbo.ContainsRepeatingAlphaChars(field1) = 1
私が言及しましたそれは遅くなるだろうか?大きなテーブルには使用しないでください。 Go CLR。
MSでも誤解を招くように他にも示唆していますが、「LIKE」は正規表現をサポートしていません。サポートするパターンは単純な文字列検索よりも強力ですが、正規表現よりも強力です。つまり、「好き」はここでは使用されそうにはありませんが、あなたが行っていることを達成するための全く異なる方法かもしれません。 – hvd