Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 SSSI csv import to a SQL table, insert/update.

Author  Topic 

exxoid
Starting Member

5 Posts

Posted - 2010-07-28 : 19:39:37
Hi,

I have a project where I need to create an SSIS package to read from our csv text file and import the values into a SQL 2005 table.

The file's first row would contain the table names, which would correspond to the ones in the SQL table, there is a "SEQ" table that contains a unique key, which I want to use to determine if the row exists already in the destination SQL table, if it does then I want to update the values otherwise insert a new row of data.

Could this be possible?

Anyone able to provide me with a sample of this? Sample of the raw csv is attached in the code snippet.

TYP|SEQ |SALEDATE|INVOICED|WEEKDATE|EWK|ZWK|IY|WK|ROMO|ROYR|YRTD|MO|YR |FM|FY |PM|PY |CO|CMP|COMPANY DESCRIPTION |FORECAST COMM |FORECAST SUB |FORECAST 3RD |F/C MISC PLAN |F/C MISCACTUAL|FLDEOL
A |2696763|7012010|7012010|7022010|27|26|10|26|0|0|2010|7|2010|7|2010|7|2010|2|DOC|OUR COMPANY NAME GOES HERE|0|0|0|0|0|2696763EOL
A |2696764|7012010|7012010|7022010|27|26|10|26|0|0|2010|7|2010|7|2010|7|2010|2|DOC|OUR COMPANY NAME GOES HERE|0|0|0|0|0|2696764EOL
A |2696765|7012010|7012010|7022010|27|26|10|26|0|0|2010|7|2010|7|2010|7|2010|2|DOC|OUR COMPANY NAME GOES HERE|0|0|0|0|0|2696765EOL
A |2696766|7012010|7012010|7022010|27|26|10|26|0|0|2010|7|2010|7|2010|7|2010|2|DOC|OUR COMPANY NAME GOES HERE|0|0|0|0|0|2696766EOL

exxoid
Starting Member

5 Posts

Posted - 2010-07-28 : 19:40:36
Basically, if you look at the "SEQ" row, the numbers will always be unique and are used to identify that record (that's how I want it setup in the SQL table). Then if the same SEQ is there, I would like to be able to update it, otherwise make a new record.

Is this possible?
Go to Top of Page
   

- Advertisement -