title: Split string with proper format
body: <p>I have one Table in my SQL Server Database like </p>
  
  <pre><code>Table1
  
   srno   Filepath      
     1     C:\Folder1\Folder2\Folder3\Files\File_1.70837292036d41139fcf8fa6b4997d3c.pdf
     2     File_2.pdf
     3     C:\File_3.pdf
     4     File_4.70837292036d41139fcf8fa6b4997d3c.pdf
     5      
     6     NULL
  </code></pre>
  
  <p>i want only srno, filename from this. </p>
  
  <p>how can i get only filename through simple query?</p>
  
  <p>Desired Output like </p>
  
  <pre><code>  srno    Filename
      1       File_1.pdf
      2       File_2.pdf
      3       File_3.pdf
      4       File_4.pdf
      5       
      6       NULL 
  </code></pre>
  
  <p>I have one Query but it is not showing proper working with ( srno 1 and 4 ) only </p>
  
  <pre><code>Select srno, CASE WHEN LEN(CHARINDEX('\', REVERSE(ISNULL(table1.Filepath,''))))= 1 THEN ISNULL(table1.Filepath,'') ELSE  REVERSE(SUBSTRING(REVERSE(ISNULL(table1.Filepath,'')), 1, CHARINDEX('\', REVERSE(ISNULL(table1.Filepath,'')))-1))  END  as Filename
  </code></pre>