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 2005 Forums
 SSIS and Import/Export (2005)
 Strip out filename from full path held in variable

Author  Topic 

patshaw
Posting Yak Master

177 Posts

Posted - 2009-02-24 : 16:59:00
I have a variable which holds the full path to a file. ie:

\\MyFTP\D$\Loads\File1.csv
or
\\MyFTP\D$\Loads\File55.csv

The file name is not static and the full path is generated and held in the variable at runtime.

From an expression, how can I strip out just the filename to put into another variable? ie.

File1
or
File55

Thanks.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-25 : 10:14:29
use SUBSTRING function along with FINDSTRING to get position of \. something like

RIGHT(@[User::variable],FINDSTRING(REVERSE(@[User::variable]),"\",1)-1)
Go to Top of Page
   

- Advertisement -