Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use VBScript regular expression features using OLE Automation. This is way better than the overhead of creating and maintaining an assembly. Please make sure you go through the comments section to get a better modified version of the main one.</p> <p><a href="http://blogs.msdn.com/b/khen1234/archive/2005/05/11/416392.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/b/khen1234/archive/2005/05/11/416392.aspx</a></p> <pre><code>DECLARE @obj INT, @res INT, @match BIT; DECLARE @pattern varchar(255) = '&lt;your regex pattern goes here&gt;'; DECLARE @matchstring varchar(8000) = '&lt;string to search goes here&gt;'; SET @match = 0; -- Create a VB script component object EXEC @res = sp_OACreate 'VBScript.RegExp', @obj OUT; -- Apply/set the pattern to the RegEx object EXEC @res = sp_OASetProperty @obj, 'Pattern', @pattern; -- Set any other settings/properties here EXEC @res = sp_OASetProperty @obj, 'IgnoreCase', 1; -- Call the method 'Test' to find a match EXEC @res = sp_OAMethod @obj, 'Test', @match OUT, @matchstring; -- Don't forget to clean-up EXEC @res = sp_OADestroy @obj; </code></pre> <p>If you get <code>SQL Server blocked access to procedure 'sys.sp_OACreate'...</code> error, use <code>sp_reconfigure</code> to enable <code>Ole Automation Procedures</code>. (Yes, unfortunately that is a server level change!)</p> <p>More information about the <code>Test</code> method is available <a href="https://msdn.microsoft.com/en-us/library/ms974570.aspx?f=255&amp;MSPPError=-2147217396" rel="nofollow noreferrer">here</a></p> <p>Happy coding</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload