sql server - MS-SQL and specific LIKE clause -
i have table in 1 column named pattern stored patterns such as: [11|01][22|88]333[4|0]. want create query similar this:
select mt.id dbo.mytable mt '11223334' mt.pattern i know pattern not correct , not work, wonder if possible create query part [22|88] (two digits or 2 digits) work. important question.
another question if solution store such patterns in db , - compare in way (please note 1 string compared multiple patterns, not 1 pattern compared multiple strings).
update
in other words - looking query more one-digit values, i.e. like '[22|88]' should values 22 or 88, not 28 or 82.
as have said pattern not correct want. [11|01] not mean 11 or 01, means single character 0, 1 or |
e.g.
select * (values ('0'), ('1'), ('|')) t (col) col '[11|01]'; will return 3 values. need define, actually, define pattern [11|01][22|88]333[4|0], logic more complicated. be:
select * (values ('11223334'), -- match ('11223335'), -- no match @ -------5 (not 0 or 4) ('11283334'), -- no match @ --28---- (not 22 or 88) ('01223334') -- match ) t (col) col '[01]1______' , (col '__22____' or col '__88____') , col '____333_' , col '_______[04]'; as such, don't think can achieve after sql servers pattern matching alone. need use clr user defined function implement regex
i don't see problem storing patterns way if fits requirements.
Comments
Post a Comment