SSIS: FINDSTRING() with backspaces

It took some time for me to figure this one out, but actually it’s pretty easy…
Apparently the SSIS coding is based on C/C#, so you’ll need to use an escape character to get the filename out of ‘Fully qualified’ path/filename.

So to get ‘FileName.txt’ out of ‘C:\Temp\FileName.txt’, you’ll need to use a combination of FINDSTRING() and REVERSE():

FINSTRING() – To find a string-part within a string
REVERSE() – Because you’re not able to select the last string-part within a string.


(DT_WSTR,50)
REVERSE(
SUBSTRING(REVERSE(@[User::FileName]),1,FINDSTRING(REVERSE(@[User::FileName]),"\\",1) - 1)
)

Advertisements

2 thoughts on “SSIS: FINDSTRING() with backspaces

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s