[dba-SQLServer] SQL Server 2005 - How to import data that could either update a row or insert a row.

Rojas, Joe joe.rojas at symmetrynb.com
Thu Feb 19 08:33:08 CST 2009


I'm using SSIS to create a Package to import data into SQL Server 2005.
I need to pull data from our ERP system via ODBC.
I'm doing this because we are pulling labor "punches" from our ERP
system into SQL Server and the processing them to be exported to our
Time and Attendance system.
Our ERP system stores the "in" punch and the "out" punch for a day in
one row.
I will be pulling the punches several times a day which will result in
some rows have both "in" and "out" punches and some rows having just an
"in" punch.
If a row just has an "in" punch, I still need to pull it. Because of
this, I will need to "re-pull" this row each time to check for an "out"
punch.

So...my question. The dataset I pull will have rows that match to an
existing row in the SQL Server table AND new rows that do not exist in
the SQL Server table.
Having one dataset pulled from the ODBC source, can I parse row by row
and, based on if the row exists, I will need to execute an UPDATE
statement or an INSERT statement?
If so, how would I do this in a data flow task?

Joe




More information about the dba-SQLServer mailing list