另一种选择可能是这样的:
Declare @Table table (col int)
Insert into @Table values
(4141243),(4290577),(98765432),(78635389),(4141243),(22222),(4290046),(55555555),(4141243),(6789),(77777),(45678),(4294461),(55555),(4141243),(5555)
Declare @Num table (Num int);Insert Into @Num values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9)
Select Distinct A.*
From @Table A
Join (
Select Patt=replicate(Num,3) from @Num
Union All
Select Patt=right('000'+cast((Num*100+Num*10+Num)+12 as varchar(5)),3) from @Num where Num<8
Union All
Select Patt=reverse(right('000'+cast((Num*100+Num*10+Num)+12 as varchar(5)),3)) from @Num where Num<8
) B on CharIndex(Patt,cast(col as varchar(25)))>0
返回
Col
5555
6789
22222
45678
55555
77777
55555555
98765432
**
想想甜酒500的组或3运行例如123或321或 333将是一个打击。
**
,你能否告诉样本数据和所需输出? –
喜添, 这里是一个小样本,期望输出 '4141243, 4290577, 98765432, 78635389, 4141243, 22222, 4290046, 55555555, 4141243, 6789, 77777, 45678, 4294461, 55555, 4141243, 5555' 所以从这个返回将是6789和98765432,没有长度标准(比为12个字符,但数量的可能的最大其他可以在1-12个字符之间) 编辑-sorry这就是有点眼睛看 – Litation