Extract Filename from Full Path

  • MSSQL2000

    I have a table with column that contains a list of Filenames such as \Server\shared\filename.xls .  Each folder and directory could be different.  I need to extract the name of the file from this column so that I only see 'filename.xls'. 

    Any simple query that will do this for me?

    Thanks!

  • selectright(FullPath, charindex('\', reverse(FullPath)) - 1)

    from

    (

    select '\Server\shared\filename.xls' as FullPath

    ) p

  • Many thanks!  I was not aware of the Reverse function so that can solve a few of my many problems.

    thanks!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply