Add Column to excel sheet import

  • I have a spreadsheet that I will have to check for and import if it's there everynight at midnight.

    One of the things I would like to do is to tack on a dateImported value to put into the column in the db, it's not a column on the spreadsheet. That way I can see when it was imported, rather than what someone filled in on the spreadsheet.

    I have:

    an excel source that grabs all the columns

    a data conversion that pretty's up some of the data

    and an OLE DB Destination for the db table

    What do I need to add to the process to drop in the timestamp of when it's updated into the db along with the rest of the data?

    thanks!

    M@

  • Probably the simplest way to accomplish this would be to add the DateColumn in the SQL table your importing to, set the default value for the column to GETDATE(), on the OLE DB Destination mapping just have it ignore the column and it will populate based on the default value.

    Hope this helps..Happy Holidays!

    Eric

  • duh, it's the easy ones that always mess me up 🙂 Thanks for the idea.:w00t:

    On the same track tho, what if I wanted to add a column that wasn't easily solvable by doing something like you suggested? Say I wanted to add my name, or some other text to a column in the target db?

  • Several ways to skin that cat,

    An easy one would be to use the Derived column task between the Source and Destination tasks. Have it create a new column and set the value to whatever fits yours need.

    I have attached a screen shot as an example for you. If these values are going to be dynamically changing then you would probably want to create a variable to hold that value, then set that column equal to the variable.

    Simple example would be using a system variable such as the Machine Name that package is running on.

    In the value field you would put... @[System::MachineName]

    Eric

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

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