Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to get filename from the filepath

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2011-05-25 : 16:32:36
I have the following, How to get just the filename?
declare @pth varchar(40)='c:\Myprojectfiles\mydoc.doc'

Thank you very much for the helpful info.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-05-25 : 16:56:43
select RIGHT(@pth, charindex('\', reverse(@pth))-1)

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -