title: How to remove extension dates in SQL Server
body: <p>How to remove extension dates in SQL server?</p>
  
  <pre><code>FileName                 | id
  -------------------------+---
  c:\abc_20181008.txt      | 1
  c:\xyz_20181007.dat      | 2 
  c:\abc_xyz_20181007.dat  | 3
  c:\ab.xyz_20181007.txt   | 4
  </code></pre>
  
  <p>Based on above data I want output like below :</p>
  
  <p>Table: emp </p>
  
  <pre><code>FileName           | id
  -------------------+---
  c:\abc.txt         | 1
  c:\xyz.dat         | 2
  c:\abc_xyz.dat     | 3
  c:\ab.xyz.txt      | 4
  </code></pre>
  
  <p>I have tried like this:</p>
  
  <pre><code>select 
      substring (Filename, replace(filename, '.', ''), len(filename)), id  
  from 
      emp
  </code></pre>
  
  <p>But this query is not returning the expected result in SQL Server.</p>
  
  <p>Please tell me how to write a query to achieve this task in SQL Server.</p>