title: SQL Server equivalent of substring_index function in MySQL
body: <p>I am trying to port a query from MySQL to SQL SERVER 2012.<br><br>
  How do i write an equivalent for MySQL's substring_index()? </p>
  
  <p>MySQL <a href="http://www.w3resource.com/mysql/string-functions/mysql-substring_index-function.php">SUBSTRING_INDEX()</a> returns the substring from the given string before a specified number of occurrences of a delimiter. </p>
  
  <p>SUBSTRING_INDEX(str, delim, count) </p>
  
  <pre><code>SELECT SUBSTRING_INDEX('www.somewebsite.com','.',2);
  </code></pre>
  
  <p>Output: <code>'www.somewebsite'</code></p>