SSIS Expression to Obtain Filename from Path

Cool post to find the Filename portion of a path that includes the filename.   Simply replace zFilename in two locations in the example below with the name of your user defined variable name.  This user defined variable must contain the full path including the filename.   Create another user defined variable to store the filename portion of the string, then assign it this expression:

REVERSE(SUBSTRING(REVERSE( @[User::zFilename] ), 1, FINDSTRING(REVERSE( @[User::zFilename] ),"\\", 1)-1))

Works a treat!

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s