Skip to content
Advertisement

How to use regular expression in T-SQL?

For example:

where strword match with {%{J{GC * GC}J} or strword={%{J{GC * GC}J}

Advertisement

Answer

I typically try to avoid posting answers that are simply links to somewhere else. But in this case it’s a fairly big answer as you have to involve CLR in your approach.

So – in this case I’m going to make an exception and just give you a link. I feel better about it since it’s an official Microsoft doc and they are pretty good about not moving things around.

Here’s the walk through from Microsoft on using RegEx with SQLServer.

It has good sample code and is extensive in it’s coverage. If your OK with adding CLR to your solution then it should give you exactly what you need.

Update: Turns out Microsoft did in fact change that link. Another walk through by a respected company (Red Gate) can be found here: https://www.red-gate.com/simple-talk/sql/t-sql-programming/clr-assembly-regex-functions-for-sql-server-by-example/

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement