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

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -