Inserting Source Table Name

  • I've got a package I'm working on and banging my head against the wall trying to think of a way to do this.

    What I've got is a Flat File lead source, which is dynamically generated at run-time for the connection string. The string has the entire file path (c:\temp\test.txt) and what I'm wanting to do is two fold.

    A) strip the path information out and simply retain test.txt (I'm fairly certain I can do this, but just in case I wanted to ask here in case someone has a good idea.

    B) as the leads are being sent from my flat-file source and into my database source, one of the fields I'd like to be able to import to my DB is the name of the flat-file itself.

    Any suggestions on where to look?

    Thanks

  • A Derived Column between the Flat File source and SQL destination might do what you want.

    If the ConnectionString for the source is set as a package variable then an expression in the Derived Column could extract the file name and allow that to be mapped to the destination along with the other columns.

    As an example, this expression will get the filename from the full path; varFileSource = c:\temp\test.txt

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

  • That worked flawlessly.

    Thanks greatly!

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

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