Regex in SQL Server to check whitespaces -
i checking invalid names(names special characters) in sql server following code
select first_name sc.name first_name '%[^a-za-z]%';
how add check leading , trailing whitespaces?
there no native regex in sql server, there pattern matching. easy way select columns end or start white space be:
select mycolumn mytable (mycolumn '% ') or (mycolumn ' %') or (mycolumn '%[^a-z]%')
a quite "heavy" search, one-time query it'll work.
of course, if looking leading , trailing white spaces, , requirement has both, use:
(mycolumn ' %[^a-z]% ')
or combination of above suit needs.
Comments
Post a Comment