Is it possible, just using TSQL, to check if the first two characters of a varchar field are alphabetical?
I need to select from my_table
only the rows havi
select * from my_table where my_field Like '[a-z][a-z]%'
You don't need to use regex, LIKE
is sufficient:
WHERE my_field LIKE '[a-zA-Z][a-zA-Z]%'
Assuming that by "alphabetical" you mean only latin characters, not anything classified as alphabetical in Unicode.
Note - if your collation is case sensitive, it's important to specify the range as [a-zA-Z]
. [a-z]
may exclude A
or Z
. [A-Z]
may exclude a
or z
.