regex - How to compare Unicode characters in SQL server? -
hi trying find rows in database (sql server) have character é in text executing following queries.
select count(*) t_question patindex(n'%[\xe9]%',question) > 0; select count(*) t_question patindex(n'%[\u00e9]%',question) > 0;
but found 2 problems: (a) both of them returning different number of rows , (b) returning rows not have specified character.
is way constructing regular expression , comparing unicode correct?
edit:
the question column stored using datatype nvarchar
. following query gives correct result though.
select count(*) t_question question n'%é%';
why not use select count(*) t_question question n'%é%'
?
nb: like
and patindex
not accept regular expressions.
in sql server pattern syntax [\xe9]
means match single character within specified set. i.e. match \
, x
, e
or 9
. of following strings match pattern.
- "elephant"
- "axis"
- "99.9"
Comments
Post a Comment