Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 REGEX or REPLACE

Author  Topic 

brendanb
Starting Member

7 Posts

Posted - 2013-11-11 : 19:29:10
Hi,

I have for example a phone number field that has a multitude of characters I want to strip out so I can do a comparison on a query. Does SQL have any built in REGEX functions?

I know I could do REPLACE(X,' ', ''), but this seems like a bad way to have to handle various characters. Like for example I could have a Space, Pipe, or some other character

regards
Brendan

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-12 : 01:46:06
you can write a CLR procedure for that. .NET has regexmatch function.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-12 : 01:47:52
see
http://msdn.microsoft.com/en-us/magazine/cc163473.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -