title: SQL Server: Select rows with multiple occurrences of regex match in a column
body: <p>I’m fairly used to using MySQL, but not particularly familiar with SQL Server. Tough luck, the database I’m dealing with here is on SQL Server 2014.</p>
  
  <p>I have a table with a column whose values are all integers with leading, separating, and trailing semicolons, like these three fictitious rows:</p>
  
  <pre><code>;905;1493;384;13387;29;933;467;28732;
  ;905;138;3084;1387;290;9353;4767;2732;
  ;9085;14493;3864;130387;289;933;4767;28732;
  </code></pre>
  
  <p>What I am trying to do now is to select all rows where <em>more than one number</em> taken from a list of numbers appears in this column. So for example, given the three rows above, if I have the group <code>905,467,4767</code>, the statement I’m trying to figure out how to construct should return the first two rows: the first row contains 905 and 467; the second row contains 905 and 4767. The third row contains only 4767, so that row should not be returned.</p>
  
  <p><a href="https://stackoverflow.com/a/9076427/1302127">As far as I can tell</a>, SQL Server does not actually support regex directly (and I don’t even know what managed code is), which doesn’t help. Even with regex, I wouldn’t know where to begin. Oracle seems to have <a href="https://docs.oracle.com/cd/B28359_01/server.111/b28286/functions135.htm#SQLRF20014" rel="nofollow noreferrer">a function that would be very useful</a>, but that’s Oracle.</p>
  
  <p>Most similar questions on here deal with finding multiple instances of the same character (usually singular) and solve the problem by <a href="https://stackoverflow.com/q/1860457">replacing the string to match with nothing and counting the difference in length</a>. I suppose that would technically work here, too, but given a ‘filter’ group of 15 numbers, the <code>SELECT</code> statement would become ridiculously long and convoluted and utterly unreadable. Additionally, I only want to match <em>entire</em> numbers (so if one of the numbers to match is 29, the value 29 would match in the first row, but the value 290 in the second row should not match), which means I’d have to include the semicolons in the <code>REPLACE</code> clause and then discount them when calculating the length. A complete mess.</p>
  
  <p>What I would ideally like to do is something like this:</p>
  
  <pre><code>SELECT * FROM table WHERE REGEXP_COUNT(column, ';(905|467|4767);') &gt; 1
  </code></pre>
  
  <p>– but that will obviously not work, for all kinds of reasons (the most obvious one being the nonexistence of <code>REGEXP_COUNT</code> outside Oracle).</p>
  
  <p>Is there some sane, manageable way of doing this?</p>