I have one Table in my SQL Server Database like
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
i want only srno, filename from this.
how can i get only filename through simple query?
Desired Output like
srno Filename
1 File_1.pdf
2 File_2.pdf
3 File_3.pdf
4 File_4.pdf
5
6 NULL
I have one Query but it is not showing proper working with ( srno 1 and 4 ) only
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