title: T SQL how to modify a string by removing all the part after the last delimiter
body: <p>I'm struggling to find the right functions with SQL Server 2008 to rectify any strings coming like: <code>\\myserver\mydir1\dir2\test.txt</code> or <code>\\myserver2\dir1\dir2\dir3\test.txt</code>.</p>
  
  <p>At the end, the result should appear like: <code>\\myserver\mydir1\dir2</code> or <code>\\myserver2\dir1\dir2\dir3</code> , So after the last <code>"\"</code> , the substring should be removed.</p>
  
  <p>Any idea how to do that?</p>